EM MICRONS Functional Data Acess

Summer Workshop on the Dynamic Brain

The MICRONS project collected a large scale functional imaging experiment from the mouse before it went through processing for electron microscopy. This notebook will teach you how to access that data and link it to the structural measurements in the electron microscopy portion of the dataset.

Background

The functional data is stored in a framework called DataJoint which is backed by MySql. DataJoint is a free, open-source framework for programming scientific databases and computational data pipelines that was developed by the Tolias Lab, and now as a for profit company. It should be pre-installed in your environment, and the json file 'dj_local_conf.json' in this folder contains the configuration about connecting to the server for you for the course. We will utilize a module called **phase3.nda**, which refers to the Microns phase 3 neural data api) to connect to the DataJoint server. The **phase3.nda** module has a module a series of tables which provide information about the functional imaging experiment, including neural activity (masks and fluorescence traces), the stimulus, the animal's behavior (running and pupil). Ultimately the functional activity of individual regions of interest is stored in the "ScanUnit" table, which can then be linked to neurons in the electron microscopy dataset via the "functional_coreg" CAVE table, which contains primary keys of that table. Outside of the course you must download this server and run it somewhere to access the data. Instructions for this can be found here. Additional documentation about the functional data and links to technical information about the dataset are here. This notebook is based on the original example notebooks provided in that repository, created by members of Andreas Tolias and Jake Reimer's groups at Baylor who created and prepared the dataset for release

Local setup instructions

to access these tables with datajoint you have to import phase3.nda, which is the primary functional data access module. We will also import phase3.func which has some helper functions for you to use, which simply use phase3.nda under the hood.

NDA Table Descriptions

Imaging Data Structure

nda.Scan: Scans are collections of frames that were acquired simultaneously. They are defined by a combination of session and scan index. Information on completed scans. Cajal Pipeline: meso.ScanInfo.

nda.ScanInclude: Scans determined suitable for analysis. Some scans did not complete successfully or had incomplete data, and so are not reccomended.

nda.Field: Individual fields of scans. Fields are single image planes. Each scan contains up to 8 fields. See here for a visualization of the scans to understand how the fields are distributed Cajal Pipeline: meso.ScanInfo.Field. On each frame of the scan, the microscope scanned one field, then hopped to the next field, and so on ina loop. So the individual 8 frames are spread out across the inter-scan frame time. All 8 frames were imaged within the 6.3Hz acquisition rate.

Functional Extraction

nda.Segmentation: CNMF segmentation of a field using CaImAn package (https://github.com/simonsfoundation/CaImAn). It records the masks of all segmented cells. Mask_id's are unique per field.
Cajal Pipeline: meso.Segmentation.Mask

nda.Fluorescence: Records the raw fluorescence traces for each segmented mask.
Cajal Pipeline: meso.Fluorescence.Trace

nda.ScanUnit: Unit_id assignment that is unique across the entire scan. Includes info about each unit.
Cajal Pipeline: meso.ScanSet.Unit / meso.ScanSet.UnitInfo

nda.MaskClassification: Classification of segmented masks into soma or artifact. Uses CaImAn package (https://github.com/simonsfoundation/CaImAn).
Cajal Pipeline: meso.MaskClassification.Type

Functional Analysis

nda.Activity: Deconvolved spike trace from the fluorescence trace.
Cajal Pipeline: meso.Activity.Trace

nda.Oracle: Measures how reliably each ScanUnit responds to visual stimulus Leave-one-out correlation for repeated videos in stimulus.

nda.AreaMembership: Visual area labels for all units.

Timing and stimulus

nda.FrameTimes: Timestamps of scan frames in seconds relative to the start of the scan for the first pixel of the first imaging field. You can use this to get a precise timing of each unit in a consistent timebase.

nda.Stimulus: For each scan, contains the movie aligned to activity traces in nda.Activity. Note, this movie is now temporly downsampled to match the acquisition rate of the activity, but does NOT reflect the temporal properties of the stimulus that was actually shown to the animal. You have to download the actual stimulus movie at 30Hz if you want precise temporarily correct information about the pixels shown to the mouse during the scan. (see below)

nda.Trial: Contains information for each trial of the movie in nda.Stimulus. There are three types of trials, Clip, Monet2, and Trippy. Each unique trial has its own condition_hash. To get detailed information for each trial stimulus, join each condition_hash according to its corresponding type in one of: nda.Clip, nda.Monet2, or nda.Trippy.

nda.Clip: Detailed information for movie clips.

nda.Monet2: Detailed information for the Monet2 stimulus.

nda.Trippy: Detailed information for the Trippy stimulus.

Behavior

nda.RawManualPupil: Pupil traces for each scan from the left eye collected at ~20 Hz and semi-automatically segmented.

nda.ManualPupil: Manual pupil traces low-pass filtered with a hamming window to the scan frame rate and linearly interpolated to scan frame times.

nda.RawTreadmill: Cylindrical treadmill rostral-caudal position extracted with a rotary optical encoder at ~100Hz and converted into velocity.

nda.Treadmill: Treadmill velocities low-pass filtered with a hamming window to the scan frame rate then linearly interpolated to scan frame times.

Co-registration

For most of your purposes, you can utilize the caveclient table 'functional_coreg' to find the ScanUnit information about neurons that have been coregistered, but if you are interested in diving into the details of the transformation, these tables are useful.

nda.MeanIntensity: Mean intensity of imaging field over time.
Cajal Pipeline: meso.Quality.MeanIntensity

nda.SummaryImages: Reference images of the scan field.
Cajal Pipeline: meso.SummaryImages

nda.Stack: High-res anatomical stack information.
Cajal Pipeline: stack.CorrectedStack

nda.Registration: Parameters of the affine matrix learned for field registration into the stack.
Cajal Pipeline: stack.Registration.Affine

nda.Coregistration: Coregistration transform solutions from the Allen Institute. em_coregistration

nda.StackUnit: Unit coordinates in stack reference frame after field registration. np_x, np_y, np_z should be used for transformation to EM space using Coregistration. meso.StackCoordinates.UnitInfo

For more documentation see: Cajal Pipeline Documentation

In [1]:
%%capture
from phase3 import nda, func
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

Table Diagram

The data from these tables are related in ways that allow you to perform certain manipulations, such as joining and merging. To help you see the relationships between these tables, the below graph represents tables as nodes and dependencies as directed edges between them. The lines indicate which tables can be joined together, as they share foriegn keys. Datajoint's design is to make merges simple by enforcing strict structure on how column names should match across tables.

Basic DataJoint tutorial and data introduction

This tutorial will focus on basic DataJoint usage and introduce the functional data in the schema. For detailed information on the contents of the schema, please find our technical documentation here.

Scan Table

Information from the completed scans are located in `nda.Scan`. A scan represents one time the mouse was put under the microscope and imaging data was collected. Each **session** happened on a single day, and **scan_idx** happened within those sessions. ***Note scan_idx is not unique**, so its the combination of **session** and **scan_idx** which is unique. Access the table by calling:
In [2]:
nda.Scan()
Out[2]:
Information on completed scan

session

Session ID

scan_idx

Scan ID

nframes

number of frames per scan

nfields

number of fields per scan

fps

frames per second (Hz)
4 7 40000 8 6.3009
4 9 35112 8 6.3009
4 10 40000 8 6.3009
5 3 40000 8 6.3009
5 6 40000 8 6.3009
5 7 40000 8 6.3009
6 2 40000 8 6.3009
6 4 40000 8 6.3009
6 6 40000 8 6.3009
6 7 40000 8 6.3009
7 3 40000 8 6.3009
7 4 40000 8 6.3009

...

Total: 19

Pandas conversion

You can convert these datajoint objects to dataframes by just declaring them as dataframes
In [3]:
pd.DataFrame(nda.Scan())
Out[3]:
session scan_idx nframes nfields fps
0 4 7 40000 8 6.30090
1 4 9 35112 8 6.30090
2 4 10 40000 8 6.30090
3 5 3 40000 8 6.30090
4 5 6 40000 8 6.30090
5 5 7 40000 8 6.30090
6 6 2 40000 8 6.30090
7 6 4 40000 8 6.30090
8 6 6 40000 8 6.30090
9 6 7 40000 8 6.30090
10 7 3 40000 8 6.30090
11 7 4 40000 8 6.30090
12 7 5 40000 8 6.30090
13 8 5 40000 8 6.30090
14 8 7 40000 8 6.30090
15 8 9 40000 8 6.30090
16 9 3 50000 6 8.61754
17 9 4 50000 6 8.61754
18 9 6 57000 4 9.62246

Primary Keys

Primary keys are a subset of its attributes that uniquely identify each entity in the table.
In [4]:
[*nda.Scan.heading.primary_key] # primary keys 
Out[4]:
['session', 'scan_idx']

Restrict to a single scan

Dictionaries serve as keys for restricting table entries. Scans are indexed by `session` and `scan_idx`. The `session` attribute is the ID indicating the imaging period for the mouse. `scan_idx` is the index of the scan within the imaging session.

the '&' syntax

Using '&' with datajoint is like doing a filter on the table. The object on the right hand side of the filter must contain primary keys of the table on the left. This can work with dictionaries you construct, assuming you name the columns to match the table you are filtering on. For example, if we want to pull out a single scan, we can construct a dictionary with that Scan's primary key.
In [5]:
scan_key = {'session': 4, 'scan_idx': 7} 
In [6]:
pd.DataFrame(nda.Scan & scan_key)
Out[6]:
session scan_idx nframes nfields fps
0 4 7 40000 8 6.3009

Task 1.1: Pick out a different scan session

In [7]:
my_scan_key = {'session': 6, 'scan_idx': 7} 
my_scan = pd.DataFrame(nda.Scan & my_scan_key)
my_scan
Out[7]:
session scan_idx nframes nfields fps
0 6 7 40000 8 6.3009

Restrict to a multiple scans

Use a list of dictionaries to restrict to multiple entries.
In [8]:
scan_keys = [{'session': 4, 'scan_idx': 7}, {'session': 5, 'scan_idx': 3}]
In [9]:
scan_res=pd.DataFrame(nda.Scan & scan_keys)
scan_res
Out[9]:
session scan_idx nframes nfields fps
0 4 7 40000 8 6.3009
1 5 3 40000 8 6.3009

Included Scans

Scans designated for inclusion into analysis are found in `nda.ScanInclude`. Restrict against `nda.Scan` to apply.
In [10]:
# here '&' filters out Scans to only include those 
# that completed successfully
pd.DataFrame(nda.Scan & nda.ScanInclude)
Out[10]:
session scan_idx nframes nfields fps
0 4 7 40000 8 6.30090
1 5 6 40000 8 6.30090
2 5 7 40000 8 6.30090
3 6 2 40000 8 6.30090
4 6 4 40000 8 6.30090
5 6 6 40000 8 6.30090
6 6 7 40000 8 6.30090
7 7 3 40000 8 6.30090
8 7 4 40000 8 6.30090
9 7 5 40000 8 6.30090
10 8 5 40000 8 6.30090
11 9 3 50000 6 8.61754
12 9 4 50000 6 8.61754
13 9 6 57000 4 9.62246

Field information

Each scan (identified by `session` and `scan_idx`) can have multiple imaging fields. These fields are indexed by the `field` attribute. `nda.Field` containes information for all imaging fields available for a scan.
In [11]:
# note that even though scan_key only has one entry
# there are multiple fields that match, so the filter
# returns all of them
nda.Field & scan_key
Out[11]:
Individual fields of scans

session

Session ID

scan_idx

Scan ID

field

Field Number

px_width

field pixels per line

px_height

lines per field

um_width

field width (microns)

um_height

field height (microns)

field_x

field x motor coordinates (microns)

field_y

field y motor coordinates (microns)

field_z

field z motor coordinates (microns)
4 7 1 248 440 620.0 1100.0 -485.0 -235.0 80.0
4 7 2 248 440 620.0 1100.0 95.0 -235.0 80.0
4 7 3 248 440 620.0 1100.0 -485.0 -235.0 220.0
4 7 4 248 440 620.0 1100.0 95.0 -235.0 220.0
4 7 5 248 440 620.0 1100.0 -485.0 -235.0 360.0
4 7 6 248 440 620.0 1100.0 95.0 -235.0 360.0
4 7 7 248 440 620.0 1100.0 -485.0 -235.0 500.0
4 7 8 248 440 620.0 1100.0 95.0 -235.0 500.0

Total: 8

Use a `field_key` to restrict to a single entry.
In [12]:
field_key = {'session': 4, 'scan_idx': 7, 'field': 4}
In [13]:
nda.Field & field_key
Out[13]:
Individual fields of scans

session

Session ID

scan_idx

Scan ID

field

Field Number

px_width

field pixels per line

px_height

lines per field

um_width

field width (microns)

um_height

field height (microns)

field_x

field x motor coordinates (microns)

field_y

field y motor coordinates (microns)

field_z

field z motor coordinates (microns)
4 7 4 248 440 620.0 1100.0 95.0 -235.0 220.0

Total: 1

Task 1.2: Find the fields in the scan you picked that have z coordinates less than 200 um? Hint, you don't have to specify all parts of the primary key to still have filter work

In [14]:
pd.DataFrame(nda.Field  & my_scan_key).query('field_z<200')
Out[14]:
session scan_idx field px_width px_height um_width um_height field_x field_y field_z
0 6 7 1 248 440 620.0 1100.0 -520.0 -280.0 100.0
1 6 7 2 248 440 620.0 1100.0 60.0 -280.0 100.0
To visualize how these scans and fields are distributed lets make a plot where each field is a line at a particular depth covering the extent of the field, and fields from the same scan get the same color. Look! we can filter with other tables too.
In [15]:
# first lets grab all the fields from included scans
fields=pd.DataFrame(nda.Field & nda.ScanInclude)
fields.groupby(['session', 'scan_idx']).field.count()
Out[15]:
session  scan_idx
4        7           8
5        6           8
         7           8
6        2           8
         4           8
         6           8
         7           8
7        3           8
         4           8
         5           8
8        5           8
9        3           6
         4           6
         6           4
Name: field, dtype: int64

Task 1.3: Make a list called scans with all the scan keys. How many unique scans are in this list of included fields?

In [30]:
scans = fields.groupby(['session', 'scan_idx']).groups.keys()
len(scans)
Out[30]:
14
In [31]:
# we need 14 colors, matplotlib standard palette has 10, so we will add 4 more
import matplotlib.colors as mcolors
colors = list(mcolors.TABLEAU_COLORS.keys()) + ['mediumblue', 'greenyellow',
                                       'peachpuff', 'darkcyan' ]
len(colors)
Out[31]:
14
In [32]:
# now lets construct a dictionary where the key is the
# combination of session, scan_idx and the color string is value
scan_colors_dict = {f:c for f,c in zip(scans, colors)}
scan_colors_dict
Out[32]:
{(4, 7): 'tab:blue',
 (5, 6): 'tab:orange',
 (5, 7): 'tab:green',
 (6, 2): 'tab:red',
 (6, 4): 'tab:purple',
 (6, 6): 'tab:brown',
 (6, 7): 'tab:pink',
 (7, 3): 'tab:gray',
 (7, 4): 'tab:olive',
 (7, 5): 'tab:cyan',
 (8, 5): 'mediumblue',
 (9, 3): 'greenyellow',
 (9, 4): 'peachpuff',
 (9, 6): 'darkcyan'}
In [33]:
# one subplot for x,z and one for y,z
f, ax = plt.subplots(2,1,figsize=(8,8))
for k, row in fields.iterrows():
    # now we can plot these as individual lines, and use our color dictionary
    # to color them
    
    # line for the x,z view
    linex = plt.Line2D([row.field_x - row.um_width/2, row.field_x+row.um_width/2], 
                       [row.field_z, row.field_z], linewidth=3, alpha=.2,
                      color=scan_colors_dict[(row.session, row.scan_idx)])
    # line for the y,z view
    liney = plt.Line2D([row.field_y - row.um_height/2, row.field_y+row.um_height/2], 
                       [row.field_z, row.field_z], linewidth=3, alpha=.2,
                      color=scan_colors_dict[(row.session, row.scan_idx)])
    ax[0].add_line(linex)
    ax[1].add_line(liney)
# #  uncomment to overlay text of field numbers 
#     text = plt.Text(x=row.field_x, y=row.field_z, text=f'{int(row.field)}')
#     texty = plt.Text(x=row.field_y-(20*int(row.field%2)), y=row.field_z, text=f'{int(row.field)}')
#     ax[0].add_artist(text)
#     ax[1].add_artist(texty)
# when using raw lines you have to set axis
ax[0].set_xlim(-900,500)
ax[0].set_ylim(650,0)
ax[0].set_aspect('equal')
ax[0].set_xlabel('+posterior ($\mu m$)')
ax[0].set_ylabel('depth ($\mu m$)')
    
ax[1].set_xlim(-900,400)
ax[1].set_ylim(650,0)
ax[1].set_aspect('equal')
ax[1].set_xlabel('+lateral ($\mu m$)')
ax[1].set_ylabel('depth ($\mu m$)')
Out[33]:
Text(0, 0.5, 'depth ($\\mu m$)')
Fields from the same Scan are now colored the same color. You can see how they are distributed in depth, and how the fields cover more medial-lateral distance than anterior-posterior. The lateral view is darker because each field perfectly overlaps and the alpha values add.

Frame Times

The timestamp of each scan frame (in seconds) relative to the start of the scan is located in `nda.FrameTimes`. Note this is the time that field=1 started. If you care to localize units with precision greater than 6.3Hz you will need to account for the fact that each from will be distributed across the 1/6.3=158ms interval.
In [34]:
nda.FrameTimes() & scan_key
Out[34]:
scan times per frame (in seconds, relative to the start of the scan)

session

Session ID

scan_idx

Scan ID

frame_times

stimulus frame times for the first pixel of field 1 of each scan (len = nframes)

ndepths

number of imaging depths recorded for each scan
4 7 =BLOB= 4

Total: 1

The `frame_times` attribute contains the timestamp for each frame synced to the first pixel of the first field (`field 1`) in `nda.Field`.
**What does =BLOB= mean**
This is a binary element in the database. Usually this is a numpy array. Note, when you convert a whole query to a dataframe it will pull that binary data out of the database. This can take a long time if the =BLOB= is big. If you don't convert, it will just list it as =BLOB=.
In [35]:
frame_times = pd.DataFrame(nda.FrameTimes & scan_key)['frame_times'].values[0]
len(frame_times)
Out[35]:
40000

Task 1.4: Plot when these frametimes occur as a raster

In [36]:
f ,ax = plt.subplots()
ax.eventplot(frame_times)
ax.set_xlim(-1,3)
Out[36]:
(-1.0, 3.0)
You can confirm that the timestamps are at the scan frame frequency by recovering the scan fps.
In [37]:
fps = pd.DataFrame(nda.Scan & scan_key).loc[0,'fps']
fps
Out[37]:
6.3009

Task 1.5: Calculate the average and std between these frametimes

In [38]:
(1 / np.diff(frame_times)).mean() # average frequency of timestamps
Out[38]:
6.298454818003098
In [39]:
np.diff(frame_times).std() # average frequency of timestamps
Out[39]:
0.0003568082788071831

Stimulus

A temporarily downsampled and synced version of the movie shown to the mouse for each scan is housed in `nda.Stimulus`. The movie is synced to the timestamps in `nda.FrameTimes`.
In [40]:
nda.Stimulus()
Out[40]:
Stimulus presented

session

Session ID

scan_idx

Scan ID

movie

stimulus images synchronized with field 1 frame times (H x W x T matrix)
4 7 =BLOB=
4 9 =BLOB=
4 10 =BLOB=
5 3 =BLOB=
5 6 =BLOB=
5 7 =BLOB=
6 2 =BLOB=
6 4 =BLOB=
6 6 =BLOB=
6 7 =BLOB=
7 3 =BLOB=
7 4 =BLOB=

...

Total: 19

Here is an example where you wouldn't want to convert this whole query result to a dataframe, as all those BLOB elements are 90x160x40000 matrices. So lets filter down first, and use a datajoin specific method **fetch1** to pull out one column from the first row. There is also **fetch** which will pull out all the rows from one or more columns.
In [41]:
movie = (nda.Stimulus & scan_key).fetch1('movie') # stimulus images synchronized with nda.FrameTimes
movie.shape #(height x width x frames)
Out[41]:
(90, 160, 40000)

Task 1.5: Look at one of the frames of this stimulus

In [42]:
f, ax = plt.subplots()
ax.imshow(movie[:,:,12000], cmap=plt.cm.gray)
Out[42]:
<matplotlib.image.AxesImage at 0x7fc62ad524f0>

Trials

A trial represents a short segment of the stimulus. Trial information is logged in `nda.Trial` and indexed by `trial_idx`. There are three types of trials: `Clip`, `Monet2`, and `Trippy`. `Clip` types show segments that contain high-entropy scenes such as Hollywood clips, sports clips and rendered movies. `Monet2` and `Trippy` types show parametric segments. Each stimulus segment has a unique identifier in its `condition_hash` and are indexed in the tables `nda.Clip`, `nda.Monet2`, and `nda.Trippy`. `start_idx` and `stop_idx` are the indices of the movie in `nda.Stimulus` during which the trial was ongoing. `start_frame_time` and `end_frame_time` are the timestamps of the `start_idx` and `end_idx` in seconds relative to the start of the scan. `frame_times` are the timestamps of every frame shown in the movie segment at the original presentation frequency (not synced to the scan). *Note that in `nda.Trial`, `frame_times` differs the attribute `frame_times` in `nda.FrameTimes`. Nomenclature will be updated and clarified in a future version.*
In [43]:
trial_df = pd.DataFrame(nda.Trial & scan_key)
trial_df
Out[43]:
session scan_idx trial_idx type start_idx end_idx start_frame_time end_frame_time frame_times condition_hash
0 4 7 0 stimulus.Clip 55 118 8.697065 18.663578 [8.697064569452493, 8.730412414530008, 8.76373... JEL5/i5FccX4ykUOKaDW
1 4 7 1 stimulus.Clip 119 182 18.763564 28.730076 [18.763563802698343, 18.796907356241434, 18.83... AAQ1HNKGrg1cIXlMw7nz
2 4 7 2 stimulus.Clip 182 245 28.830070 38.796571 [28.830070426920145, 28.86340229795286, 28.896... ksTS42zV+O0YJqa0+s4Y
3 4 7 3 stimulus.Clip 246 308 38.896565 48.863070 [38.89656536863157, 38.92988865659544, 38.9632... m5JLObtSRnbRKw1ukcSE
4 4 7 4 stimulus.Clip 309 372 48.963060 58.929562 [48.963060310342996, 48.996388843515604, 49.02... L8Z/mji+v1WipuJe4GaL
... ... ... ... ... ... ... ... ... ... ...
459 4 7 459 stimulus.Clip 31548 31611 5008.780256 5018.746762 [5008.780256441096, 5008.813589504221, 5008.84... owkBHih6INnj1E45lT8d
460 4 7 460 stimulus.Trippy 31612 31706 5018.846758 5033.829829 [5018.846758296946, 5018.863422325114, 5018.88... 5/1FqWTahoTvRpmjfXdl
461 4 7 461 stimulus.Trippy 31707 31801 5033.913160 5048.896257 [5033.91316049383, 5033.929828336695, 5033.946... +4gByvU9LfvSD0JHP6Ae
462 4 7 462 stimulus.Trippy 31801 31896 5048.979574 5063.962665 [5048.979574373225, 5048.996248414973, 5049.01... S3YyVltepwIk1BYeNSvC
463 4 7 463 stimulus.Trippy 31896 31991 5064.045994 5079.029088 [5064.045994451502, 5064.062659433344, 5064.07... EhwIk1vM51LHZPE6xFZX

464 rows × 10 columns

Task 1.7: How many trial types are there? And how many total trials?

In [44]:
trial_df.type.value_counts()
Out[44]:
stimulus.Clip      384
stimulus.Monet2     40
stimulus.Trippy     40
Name: type, dtype: int64
In [45]:
len(trial_df)
Out[45]:
464
In [ ]:
 

Task 1.8: How many times was each unique stimulus shown? (save this as a dataframe)

In [46]:
n_stimulus_df = trial_df.groupby('condition_hash').session.count()
n_stimulus_df.sort_values(ascending=False)
Out[46]:
condition_hash
5zQTb77qI+ig8rigx1XU    10
ecUQJtcERZJGdqza1k7h    10
GjCMo2GkJp6y5vricadg    10
7UETOWO5Z8aWuHDBJ2GG    10
Oup5uAZxF2G7zEJkT+ui    10
                        ..
DCM6Wd1w6zoYhtjnrQal     1
D3JX/fT6PFESorDVkSNi     1
aAFp4NDz9KOYeXAukger     1
aEAvIEfOqtneG1jn9rtY     1
U+1qcBHNmS5KSpBpTbu1     1
Name: session, Length: 280, dtype: int64

Task 1.9: What are the hashes for the stimuli that are repeated 10 times?

In [47]:
n_stimulus_df[n_stimulus_df>9]
Out[47]:
condition_hash
5zQTb77qI+ig8rigx1XU    10
7UETOWO5Z8aWuHDBJ2GG    10
GjCMo2GkJp6y5vricadg    10
KXdTNAGMo1gCWz2Ge8zr    10
Oup5uAZxF2G7zEJkT+ui    10
ecUQJtcERZJGdqza1k7h    10
Name: session, dtype: int64

Task 1.10: Do the same thing for a different scan, and then figure out how many stimuli were presented in both scans? hint: you can do merge using a series, if you want to use the index to merge, use left/right_index=True.

In [48]:
trial2_df = pd.DataFrame(nda.Trial & my_scan_key)
In [49]:
n_stimulus_df2 = trial2_df.groupby('condition_hash').session.count()
In [50]:
stim_merge_df=pd.merge(n_stimulus_df, n_stimulus_df2, how='inner', left_index=True, right_index=True)
In [51]:
stim_merge_df
Out[51]:
session_x session_y
condition_hash
+4gByvU9LfvSD0JHP6Ae 2 2
+rgSVBVRE8Ij1WNhq8ZW 2 2
0JcYLY6eaQxNgD0AqyHf 2 2
0eP/PPhAGmbJ2peZOa/E 2 2
0ir9/br3yxbe2BBf65zF 2 2
... ... ...
yfFAPn1QpVQmEC2iXg07 2 2
ysjy6YgGXX5+mcx52KSM 2 2
yv/S61fYnDSQcA9J6Nk8 2 2
zcz9H/fzww6BdAJTTzoe 2 2
zlQ935qW1A8YOiseS7gY 2 2

116 rows × 2 columns

Detailed information about the stimulus during each trial can be obtained by restricting into the appropriate type-specific table. The example trial_key below restricts to a `Monet2` type trial.
In [52]:
trial_key = {'session': 4, 'scan_idx': 7, 'trial_idx': 8}
In [53]:
trial_info = nda.Trial & trial_key
trial_info
Out[53]:
Information for each Trial

session

Session ID

scan_idx

Scan ID

trial_idx

index of trial within stimulus

type

type of stimulus trial

start_idx

index of field 1 scan frame at start of trial

end_idx

index of field 1 scan frame at end of trial

start_frame_time

start time of stimulus frame relative to scan start (seconds)

end_frame_time

end time of stimulus frame relative to scan start (seconds)

frame_times

full vector of stimulus frame times relative to scan start (seconds)

condition_hash

120-bit hash (The first 20 chars of MD5 in base64)
4 7 8 stimulus.Monet2 626 720 99.24554627225706 114.22863238141844 =BLOB= GHn0W57E+2PS+Qr5yD2r

Total: 1

Join `trial_info` with `nda.Monet2` using the `*` operator to get all available information about the stimulus during that trial.

The * operator

The * operator is like pandas merge with how='inner' so it finds all the rows that match on both sides. It doesn't need to specify left_on, right_on or on, because the matching keys are already programmed into the relational database.

Monet2

For this join in particular, `Monet2` is a directional stimuli, and the vector of directions during the trial is stored in the `directions` attribute. See technical methods for a more detailed description of the contents of this and other stimulus type tables.
In [54]:
trial_info * nda.Monet2
Out[54]:

session

Session ID

scan_idx

Scan ID

trial_idx

index of trial within stimulus

condition_hash

120-bit hash (The first 20 chars of MD5 in base64)

type

type of stimulus trial

start_idx

index of field 1 scan frame at start of trial

end_idx

index of field 1 scan frame at end of trial

start_frame_time

start time of stimulus frame relative to scan start (seconds)

end_frame_time

end time of stimulus frame relative to scan start (seconds)

frame_times

full vector of stimulus frame times relative to scan start (seconds)

fps

display refresh rate

duration

(s) trial duration

rng_seed

random number generator seed

blue_green_saturation

0 = grayscale, 1=blue/green

pattern_width

width of generated pattern

pattern_aspect

the aspect ratio of the pattern

temp_kernel

temp_bandwidth

(Hz) temporal bandwidth of the stimulus

ori_coherence

1=unoriented noise. pi/ori_coherence = bandwidth of orientations.

ori_fraction

fraction of time coherent orientation is on

ori_mix

mixin-coefficient of orientation biased noise

n_dirs

number of directions

speed

unit/s motion component, where unit is display width

directions

computed directions of motion in degrees

onsets

computed direction onset (seconds)

movie

rendered uint8 movie (H X W X 1 X T)
4 7 8 GHn0W57E+2PS+Qr5yD2r stimulus.Monet2 626 720 99.24554627225706 114.22863238141844 =BLOB= 60.000 15.000 8.0 0.000 72 1.7 hamming 4.00 2.50 1.0 1.0 16 0.2 =BLOB= =BLOB= =BLOB=

Total: 1

We can get the actual stimulus movie shown, and the timing of the individual frames from these more detailed tables. Note, the timing of these frames is now 60Hz
In [58]:
monet_info=trial_info * nda.Monet2
mov_frame_times = monet_info.fetch1('frame_times')
mov = monet_info.fetch1('movie')
In [59]:
1/np.diff(mov_frame_times).mean()
Out[59]:
60.000990013019305
In [61]:
mov.shape
Out[61]:
(126, 216, 1, 900)
Lets plot 8 frames from the movie. Feel free to play around with the offset and skips to see different parts
In [62]:
offset = 45
skips = 5
fig, axs = plt.subplots(1, 8, dpi=150, figsize=(16,4)) 
for n in range(8):
    axs[n].imshow(mov[:,:,0,n*skips+offset], cmap='gray')
[ax.axis('off') for ax in axs.ravel()];
In [63]:
directions, onsets = monet_info.fetch1('directions', 'onsets')
directions_df = pd.DataFrame({'onset': onsets[0,:], 'direction':directions[0,:]})
duration = float(monet_info.fetch1('duration'))
offsets = np.concatenate([directions_df['onset'][1:],[duration]])
directions_df['offset']=offsets
directions_df
Out[63]:
onset direction offset
0 0.0000 202.5 0.9375
1 0.9375 90.0 1.8750
2 1.8750 180.0 2.8125
3 2.8125 45.0 3.7500
4 3.7500 67.5 4.6875
5 4.6875 315.0 5.6250
6 5.6250 22.5 6.5625
7 6.5625 225.0 7.5000
8 7.5000 292.5 8.4375
9 8.4375 270.0 9.3750
10 9.3750 337.5 10.3125
11 10.3125 112.5 11.2500
12 11.2500 157.5 12.1875
13 12.1875 0.0 13.1250
14 13.1250 247.5 14.0625
15 14.0625 135.0 15.0000

Task 1.11: At what time in the scan did this Trial start showing a 315 degree oriented stimulus?

In [64]:
directions_df.query('direction==315').onset +trial_info.fetch('start_frame_time')
Out[64]:
5    103.933046
Name: onset, dtype: float64
How might we find frames based upon these event times. Using np.searchsorted with the frame_times can help here.
In [65]:
directions_df['onset_time']=directions_df['onset']+monet_info.fetch1('start_frame_time')
directions_df['offset_time']=directions_df['offset']+monet_info.fetch1('start_frame_time')

directions_df['onset_frame_number']=np.searchsorted(frame_times, directions_df.onset_time)
directions_df['offset_frame_number']=np.searchsorted(frame_times, directions_df.offset_time)

# sort the times with respect to directions
directions_df.sort_values('direction', inplace=True)
In [66]:
directions_df
Out[66]:
onset direction offset onset_time offset_time onset_frame_number offset_frame_number
13 12.1875 0.0 13.1250 111.433046 112.370546 703 708
6 5.6250 22.5 6.5625 104.870546 105.808046 661 667
3 2.8125 45.0 3.7500 102.058046 102.995546 643 649
4 3.7500 67.5 4.6875 102.995546 103.933046 649 655
1 0.9375 90.0 1.8750 100.183046 101.120546 632 638
11 10.3125 112.5 11.2500 109.558046 110.495546 691 697
15 14.0625 135.0 15.0000 113.308046 114.245546 714 720
12 11.2500 157.5 12.1875 110.495546 111.433046 697 703
2 1.8750 180.0 2.8125 101.120546 102.058046 638 643
0 0.0000 202.5 0.9375 99.245546 100.183046 626 632
7 6.5625 225.0 7.5000 105.808046 106.745546 667 673
14 13.1250 247.5 14.0625 112.370546 113.308046 708 714
9 8.4375 270.0 9.3750 107.683046 108.620546 679 685
8 7.5000 292.5 8.4375 106.745546 107.683046 673 679
5 4.6875 315.0 5.6250 103.933046 104.870546 655 661
10 9.3750 337.5 10.3125 108.620546 109.558046 685 691
Use `start_idx` and `end_idx` to view the part of the stimulus corresponding to the trial.
In [67]:
#start, end = pd.DataFrame(trial_info * nda.Monet2).loc[0,['start_idx', 'end_idx']] # Fetch indices of trial
#print(f'Trial starts at index: {start} and ends at index {end}')
In [68]:
# we can slice the stimulus aligned movie according to indices of trial
onset_trial_slice = movie[:,:,directions_df.onset_frame_number] 
offset_trial_slice = movie[:,:,directions_df.offset_frame_number-1] 
onset_trial_slice.shape
Out[68]:
(90, 160, 16)
In [69]:
fig, axs = plt.subplots(16, 4, dpi=150, figsize=(4,16)) 
for n in range(onset_trial_slice.shape[2]):
    axs[n,0].imshow(onset_trial_slice[:,:,n], cmap='gray')
    axs[n,1].imshow(offset_trial_slice[:,:,n], cmap='gray')
    #axs[0].set_title(f'direction: {start}')
#axs[1].imshow(stimulus_trial_slice[:,:,-1], cmap='gray')
#axs[1].set_title(f'frame: {end}')
[ax.axis('off') for ax in axs.ravel()];

Stimulus from AWS Bucket

The stimuli presented above are temporarily downsampled and aligned to the functional recording as convienient ways to represent stimulus and activity in the same index. However, the actual stimulus shown to the animal was presented at 60Hz, with the first frame starting at time=0. The complete 60Hz stimulus shown during each scan can be downloaded from an AWS bucket.
In [70]:
import requests
import skvideo.io
In [71]:
base_url = 'https://bossdb-open-data.s3.amazonaws.com/iarpa_microns/minnie/functional_data/stimulus_movies'
In [72]:
filename = f'stimulus_17797_{scan_key["session"]}_{scan_key["scan_idx"]}_v1.avi'
In [73]:
url = base_url + '/' + filename
url
Out[73]:
'https://bossdb-open-data.s3.amazonaws.com/iarpa_microns/minnie/functional_data/stimulus_movies/stimulus_17797_4_7_v1.avi'
Uncomment the below cell to download movie. Each movie is approx 2GB movie. This will write the stimulus to the current directory as an avi.
In [74]:
# movie_aws = requests.get(url) 

# with open(filename, 'wb') as f:
#     f.write(movie_aws.content) 

Summary Image

A summary image of the field can be found in `nda.SummaryImages`. There are two types of images available, `correlation` and `average`. Details of how these are computed can be found in the accompanying methods.
In [75]:
nda.SummaryImages & field_key
Out[75]:

session

Session ID

scan_idx

Scan ID

field

Field Number

correlation

correlation image

average

average image
4 7 4 =BLOB= =BLOB=

Total: 1

Fetch and View Image

In [76]:
corr, avg = (nda.SummaryImages & field_key).fetch1('correlation', 'average')
In [77]:
fig, axs = plt.subplots(1, 3, figsize=(10,6), dpi=200)
axs[0].imshow(corr)
axs[0].set_title('correlation image')
axs[1].imshow(avg)
axs[1].set_title('average image')
axs[2].imshow(corr*avg) # gives a good view of the cell bodies and darkens vessels
axs[2].set_title('correlation * average image')
[ax.axis('off') for ax in axs];
[ax.set_aspect('auto') for ax in axs];

Masks

The functional ROI segmentation gives a set of 2D masks indexed by `mask_id`, which are unique per `field`. A cell that was scanned in more than one imaging field will have more than one mask. Masks are stored in `nda.Segmentation`. Classification of masks as `soma` or `artifact` is stored in `nda.MaskClassification`. See technical documentation for further details on segmentation and classification methods.
In [78]:
nda.Segmentation * nda.MaskClassification & field_key
Out[78]:

session

Session ID

scan_idx

Scan ID

field

Field Number

mask_id

pixels

indices into the image in column major (Fortran) order

weights

weights of the mask at the indices above

mask_type

classification of mask as soma or artifact
4 7 4 1 =BLOB= =BLOB= artifact
4 7 4 2 =BLOB= =BLOB= soma
4 7 4 3 =BLOB= =BLOB= soma
4 7 4 4 =BLOB= =BLOB= artifact
4 7 4 5 =BLOB= =BLOB= soma
4 7 4 6 =BLOB= =BLOB= soma
4 7 4 7 =BLOB= =BLOB= soma
4 7 4 8 =BLOB= =BLOB= soma
4 7 4 9 =BLOB= =BLOB= artifact
4 7 4 10 =BLOB= =BLOB= artifact
4 7 4 11 =BLOB= =BLOB= artifact
4 7 4 12 =BLOB= =BLOB= soma

...

Total: 1389

Fetch masks and plot over the summary image to view them. *Note: the image below is intended to show the density and location of masks, but to better visualize the shape and weights of individual masks, plot them one at a time.*
In [79]:
# function that will retrieve masks in convenient format and optionally plot
masks = func.get_all_masks(field_key, mask_type='soma', plot=True) 

Single Unit Information

For the purposes of this schema, a `unit` is a re-indexing of all masks across all imaging fields of a scan and indexed by `unit_id`. `unit_id` is unique per scan. Note: `unit_id` is not a consolidation step, only re-indexing. Therefore, if a cell was scanned in multiple imaging fields within the scan, it will have multiple `mask_id's`, and it will also have multiple `unit_id's`. Information for all units in the scan can be found in `nda.ScanUnit`. This table can be used to relate `mask_id` to its `unit_id`. unit coordinates (`um_x`, `um_y`, `um_z`) are in microns and in the original motor reference frame (see technical documentation for more info). unit coordinate (`px_x` and `px_y` are the unit coordinates in image pixels). this table can also be used to relate `unit_id's` and `mask_id's` that are used in nda.Segmentation and nda.Fluorescence
In [80]:
nda.ScanUnit() & scan_key & {'field':2}
Out[80]:
single unit in the scan

session

Session ID

scan_idx

Scan ID

unit_id

unique per scan

field

Field Number

mask_id

mask id unique per field

um_x

centroid x motor coordinates (microns)

um_y

centroid y motor coordinates (microns)

um_z

centroid z motor coordinates (microns)

px_x

centroid x pixel coordinate in field (pixels)

px_y

centroid y pixel coordinate in field (pixels)

ms_delay

delay from start of frame (field 1 pixel 1) to recording of this unit (milliseconds)
4 7 644 2 1 87 -670 80 121 46 21
4 7 645 2 2 -146 -560 80 28 90 23
4 7 646 2 3 -7 -552 80 83 93 23
4 7 647 2 4 81 -566 80 119 87 23
4 7 648 2 5 -109 -470 80 42 126 25
4 7 649 2 6 -142 -442 80 29 137 25
4 7 650 2 7 -121 -436 80 38 140 25
4 7 651 2 8 46 -462 80 104 129 25
4 7 652 2 9 94 -460 80 123 130 25
4 7 653 2 10 243 -396 80 183 156 26
4 7 654 2 11 -205 -353 80 4 173 27
4 7 655 2 12 -119 -348 80 38 175 27

...

Total: 452

Calcium Fluorescence Traces

Each mask has a GCaMP6 fluorescence trace in `nda.Fluorescence`.
In [81]:
nda.Fluorescence() & field_key
Out[81]:
fluorescence traces before spike extraction or filtering

session

Session ID

scan_idx

Scan ID

field

Field Number

mask_id

mask ID, unique per field

trace

fluorescence trace
4 7 4 1 =BLOB=
4 7 4 2 =BLOB=
4 7 4 3 =BLOB=
4 7 4 4 =BLOB=
4 7 4 5 =BLOB=
4 7 4 6 =BLOB=
4 7 4 7 =BLOB=
4 7 4 8 =BLOB=
4 7 4 9 =BLOB=
4 7 4 10 =BLOB=
4 7 4 11 =BLOB=
4 7 4 12 =BLOB=

...

Total: 1389

In [82]:
calcium_trace = (nda.Fluorescence() & field_key & {'mask_id': 500}).fetch1('trace')
In [83]:
fig, ax = plt.subplots(figsize=(10, 3), dpi=150)
ax.plot(frame_times, calcium_trace, c='g')
ax.set_xlabel('time (sec)')
ax.set_ylabel('Fluorescence')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
In [84]:
# lets zoom in on one portion to see some transients
fig, ax = plt.subplots(figsize=(10, 3), dpi=150)
ax.plot(frame_times[3000:4000], calcium_trace[3000:4000], c='g')
ax.set_xlabel('Time (sec)')
ax.set_ylabel('Fluorescence')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)

Task 1.11: Pull out all the fluorescence traces from a single field. Hint, use * join on a filtered ScanUnit table. Use fetch to return all the traces, use np.vstack to concatentate them all together into a matrix.

In [85]:
fluor=(nda.ScanUnit() & scan_key & {'field':2}) * nda.Fluorescence()
fluor
Out[85]:

session

Session ID

scan_idx

Scan ID

unit_id

unique per scan

field

Field Number

mask_id

mask ID, unique per field

um_x

centroid x motor coordinates (microns)

um_y

centroid y motor coordinates (microns)

um_z

centroid z motor coordinates (microns)

px_x

centroid x pixel coordinate in field (pixels)

px_y

centroid y pixel coordinate in field (pixels)

ms_delay

delay from start of frame (field 1 pixel 1) to recording of this unit (milliseconds)

trace

fluorescence trace
4 7 644 2 1 87 -670 80 121 46 21 =BLOB=
4 7 645 2 2 -146 -560 80 28 90 23 =BLOB=
4 7 646 2 3 -7 -552 80 83 93 23 =BLOB=
4 7 647 2 4 81 -566 80 119 87 23 =BLOB=
4 7 648 2 5 -109 -470 80 42 126 25 =BLOB=
4 7 649 2 6 -142 -442 80 29 137 25 =BLOB=
4 7 650 2 7 -121 -436 80 38 140 25 =BLOB=
4 7 651 2 8 46 -462 80 104 129 25 =BLOB=
4 7 652 2 9 94 -460 80 123 130 25 =BLOB=
4 7 653 2 10 243 -396 80 183 156 26 =BLOB=
4 7 654 2 11 -205 -353 80 4 173 27 =BLOB=
4 7 655 2 12 -119 -348 80 38 175 27 =BLOB=

...

Total: 452

In [86]:
F=fluor.fetch('trace')
F
Out[86]:
array([array([-17.700603,  49.312416,  43.1653  , ...,  53.64555 , 154.35057 ,
              115.52162 ], dtype=float32)                                     ,
       array([57.50622  , 74.11323  ,  2.7417843, ..., 74.89302  , 23.326519 ,
              -1.6611774], dtype=float32)                                     ,
       array([52.478912, 16.43683 , 33.406353, ..., 39.488457, 32.297337,
              20.9168  ], dtype=float32)                                 ,
       array([-12.319521, -25.868952,   4.250293, ...,  36.00836 ,  -0.660595,
               55.47509 ], dtype=float32)                                     ,
       array([20.25117 , 21.56239 , -9.004405, ..., 12.784739, 55.154667,
              27.247154], dtype=float32)                                 ,
       array([23.222157, 35.00185 , 22.134014, ..., 34.947796, 34.25752 ,
              28.925497], dtype=float32)                                 ,
       array([ 14.531469 ,   3.0383487, -32.372585 , ...,  26.886889 ,
                2.2046714,  35.945927 ], dtype=float32)               ,
       array([44.9388  , 15.333386, 75.13128 , ..., 15.789336, 16.237127,
              35.08697 ], dtype=float32)                                 ,
       array([ 49.355797, -12.361184,  28.695513, ...,  21.76151 ,  42.324917,
               55.516773], dtype=float32)                                     ,
       array([ 33.354473, -11.302059,  39.946663, ...,  26.919924,  17.6749  ,
               38.73648 ], dtype=float32)                                     ,
       array([28.43608 , 26.906569, 24.215025, ...,  8.765736, 21.833866,
              22.619272], dtype=float32)                                 ,
       array([ 12.88404 ,  86.96808 ,  56.406815, ...,  14.637604, -49.799007,
                8.143722], dtype=float32)                                     ,
       array([66.6964  , 85.93194 , 42.35524 , ..., 49.46484 , 24.47011 ,
              18.039713], dtype=float32)                                 ,
       array([95.13944 , 61.083454, 43.584293, ..., 73.40217 ,  1.39554 ,
              61.661823], dtype=float32)                                 ,
       array([79.09809 , 25.283218, 59.465412, ..., 27.480755, 18.182104,
              36.046078], dtype=float32)                                 ,
       array([100.02583 ,  43.24615 ,  28.48972 , ...,  12.980695,  23.840553,
               11.906016], dtype=float32)                                     ,
       array([ 21.560291 , -16.377972 ,  -6.0740943, ..., -48.59617  ,
              -18.291056 ,  22.711184 ], dtype=float32)               ,
       array([15.536628 ,  6.2849703,  8.819455 , ...,  3.9620469, -1.6346684,
              18.680317 ], dtype=float32)                                     ,
       array([118.555984 ,  24.766588 ,  70.08022  , ...,  -3.7761588,
              -21.94663  ,  66.223274 ], dtype=float32)               ,
       array([ 97.03738 , 108.971436,  23.586023, ..., -14.1526  ,  -8.528526,
               -5.041514], dtype=float32)                                     ,
       array([ 96.38854 ,  73.907036, 122.273224, ...,  49.36943 ,  -8.764109,
               45.105434], dtype=float32)                                     ,
       array([32.199493  , 20.51914   ,  0.16746327, ..., 53.30635   ,
              25.750946  , 29.475529  ], dtype=float32)               ,
       array([125.004    , 111.49444  ,   7.8459797, ...,   4.3748164,
              -17.393417 , -22.888767 ], dtype=float32)               ,
       array([85.733246 , 16.69866  , 50.408306 , ..., 24.868233 , -0.8307447,
              28.338366 ], dtype=float32)                                     ,
       array([52.10884 , 42.686337, 65.60523 , ..., 18.784082, 30.604153,
              32.33743 ], dtype=float32)                                 ,
       array([36.5956   , 43.55474  , 13.125066 , ..., 27.142948 , 18.154198 ,
               3.5781865], dtype=float32)                                     ,
       array([30.2821   ,  2.6229072, 54.657692 , ..., 16.031433 ,  5.5630455,
              23.422997 ], dtype=float32)                                     ,
       array([ 69.28356  , -17.351593 ,  39.679173 , ...,  -1.0014917,
                8.2119055,  43.90289  ], dtype=float32)               ,
       array([ 53.73076 ,  54.5232  ,  68.90041 , ...,  13.060716, -11.147834,
               33.83466 ], dtype=float32)                                     ,
       array([39.381535 , 49.78048  ,  1.8985796, ..., 17.860275 , -3.0292315,
              39.596703 ], dtype=float32)                                     ,
       array([58.51706  ,  3.7804914, 40.935226 , ...,  7.320991 , 17.480003 ,
              -3.8722248], dtype=float32)                                     ,
       array([449.16528 , 362.13663 , 358.02875 , ...,  17.103928, -21.224022,
               23.59767 ], dtype=float32)                                     ,
       array([31.569323, 22.393719, 29.206694, ..., 24.903158, 57.021637,
              23.29607 ], dtype=float32)                                 ,
       array([135.74341 , 133.78084 , 117.06855 , ..., -10.934167, -10.510455,
              -14.98389 ], dtype=float32)                                     ,
       array([11.602903, 43.432373, 32.71441 , ..., -1.874429, -8.706152,
              40.957546], dtype=float32)                                 ,
       array([77.50588 , 61.171135, 67.13704 , ..., 25.057646,  8.436238,
              29.815687], dtype=float32)                                 ,
       array([ 38.56221 ,  52.244633,  16.93938 , ...,  11.377101, -16.54273 ,
               24.461279], dtype=float32)                                     ,
       array([66.49883  ,  3.8629692, 44.322147 , ..., 27.346893 , 28.368147 ,
              42.16386  ], dtype=float32)                                     ,
       array([21.449043 , 30.953856 ,  1.8682066, ..., 23.576038 , 23.94928  ,
               8.010679 ], dtype=float32)                                     ,
       array([113.13658  ,  36.878963 ,  68.42751  , ...,  46.14499  ,
              -11.181146 ,  -7.3737392], dtype=float32)               ,
       array([52.759815, 41.231888, 85.86913 , ...,  8.078138,  9.730503,
              16.640955], dtype=float32)                                 ,
       array([74.73009  , 53.350536 , 38.59745  , ...,  1.2078903, 39.272785 ,
              69.39258  ], dtype=float32)                                     ,
       array([149.94972 ,  83.24869 , 197.2578  , ...,  87.65908 ,  76.917595,
               65.1013  ], dtype=float32)                                     ,
       array([-13.653163,  32.67828 ,  17.8564  , ...,  21.922722, -16.90156 ,
               31.131136], dtype=float32)                                     ,
       array([  4.3835483, -25.435614 ,  71.88644  , ...,   7.0578427,
               12.604587 ,  54.717857 ], dtype=float32)               ,
       array([52.13401 , 36.76527 , 32.25972 , ..., 21.525703, 16.166018,
              22.280104], dtype=float32)                                 ,
       array([33.049454 , 41.63681  ,  3.1845284, ..., 19.857689 , 28.242657 ,
              99.538055 ], dtype=float32)                                     ,
       array([23.524996, 38.66637 , 22.209602, ..., 11.856684, 36.591824,
              13.609148], dtype=float32)                                 ,
       array([-7.318353, 36.115025, 93.69837 , ..., -5.069037, 31.580698,
              69.140854], dtype=float32)                                 ,
       array([68.74566  , 21.405441 ,  4.854109 , ..., 30.994644 ,  9.16288  ,
               2.8712397], dtype=float32)                                     ,
       array([-14.929606 ,   7.4358897,  10.084245 , ...,  38.429653 ,
               40.23658  ,  44.710663 ], dtype=float32)               ,
       array([101.77738 ,  84.43473 ,  93.46451 , ...,  45.794846,  49.72915 ,
               37.561703], dtype=float32)                                     ,
       array([54.091576, 26.234873, 12.809801, ..., 11.270266, -9.181697,
               7.967676], dtype=float32)                                 ,
       array([20.218645, 33.218307, 59.937847, ..., 30.367008, 20.461124,
              15.111072], dtype=float32)                                 ,
       array([46.31069 ,  8.029847, 36.816772, ..., 42.90015 , 51.936626,
              40.139706], dtype=float32)                                 ,
       array([149.83366  , 107.08499  , 124.94859  , ...,  -7.311983 ,
                2.5715237,  -7.1932383], dtype=float32)               ,
       array([116.58164  ,  88.17101  ,  58.64501  , ...,   7.6048512,
               -7.3576536,   9.445563 ], dtype=float32)               ,
       array([ 45.90076 ,  32.463886,  35.94663 , ..., -22.131453,  31.246977,
               18.119541], dtype=float32)                                     ,
       array([57.212383, 41.19167 , 23.851536, ..., 43.988876, 19.400547,
              64.16236 ], dtype=float32)                                 ,
       array([123.82718  ,  -6.5504365,  68.463394 , ...,  42.731644 ,
               -1.9844729,  37.14521  ], dtype=float32)               ,
       array([ 66.44931 ,  46.217777,  48.63609 , ..., -17.839687,  43.987003,
               53.844715], dtype=float32)                                     ,
       array([ 38.21793 , -31.240723,  21.064117, ..., 107.08791 ,  66.048454,
               52.043858], dtype=float32)                                     ,
       array([  8.440571, -26.086304, -25.459196, ...,   9.868495,  13.845292,
               23.597624], dtype=float32)                                     ,
       array([91.41175  , 27.625187 , 25.2551   , ...,  5.5982075, -2.2632704,
              -9.761079 ], dtype=float32)                                     ,
       array([ -8.005542 ,  24.643383 ,  -1.7242837, ..., -37.87684  ,
              -14.672522 ,  36.672756 ], dtype=float32)               ,
       array([ -1.7341838, -16.473227 ,  36.530785 , ...,  18.65367  ,
               49.208897 ,  26.745985 ], dtype=float32)               ,
       array([74.37423   , 38.411003  , 17.835619  , ...,  0.52856433,
               4.1994658 , 10.909828  ], dtype=float32)               ,
       array([92.11507  , 52.64642  , 95.5627   , ..., 35.299625 , 64.63018  ,
               1.8364543], dtype=float32)                                     ,
       array([45.58549 , 14.477849, 27.67844 , ..., 16.574757, 15.584245,
              22.63211 ], dtype=float32)                                 ,
       array([118.87218 ,  69.78286 ,  62.42473 , ...,  25.485428,  -9.489257,
               28.709259], dtype=float32)                                     ,
       array([  71.57351 ,  -19.680431, -100.94282 , ...,  -14.515312,
               -16.976002,   11.531021], dtype=float32)               ,
       array([73.06389  , 13.481495 , 40.13094  , ..., 26.39118  , -4.5126667,
              15.687696 ], dtype=float32)                                     ,
       array([85.037636 , 42.868015 , 24.167812 , ..., 21.572731 , 24.727411 ,
               7.9471164], dtype=float32)                                     ,
       array([-16.01294   , -75.42608   ,  -3.2986584 , ..., -72.85579   ,
                4.875955  ,   0.97734654], dtype=float32)                 ,
       array([139.3661  ,  89.19717 ,  34.59019 , ...,  42.67927 ,  20.531324,
               12.783111], dtype=float32)                                     ,
       array([271.8524   , 167.92735  , 128.5078   , ...,  21.369473 ,
               -5.9914107,  10.440172 ], dtype=float32)               ,
       array([46.584816, 31.626095, 13.11639 , ...,  3.652834, 23.398993,
              70.07141 ], dtype=float32)                                 ,
       array([145.75687 ,  58.725082,  12.564879, ...,  65.220055,  -2.714381,
              -27.42287 ], dtype=float32)                                     ,
       array([47.749527 , 78.57568  , 51.033344 , ...,  3.262245 , 34.46954  ,
               7.1600323], dtype=float32)                                     ,
       array([ 53.707542 , -43.5321   ,   7.7062554, ..., -13.244367 ,
                8.5380335,  13.360854 ], dtype=float32)               ,
       array([ 51.33779 , -41.377327, -22.360668, ...,  -3.699636, -14.158005,
               -6.223731], dtype=float32)                                     ,
       array([54.442547 , 23.216398 , -4.0693207, ..., 84.82789  , 91.26755  ,
              82.06845  ], dtype=float32)                                     ,
       array([  8.022685 , -33.463455 , -32.395042 , ...,  11.315526 ,
               26.022108 ,   5.6229386], dtype=float32)               ,
       array([102.430954,  58.627533,  60.72243 , ...,   8.712411,  66.5233  ,
               19.77434 ], dtype=float32)                                     ,
       array([ 13.472848  , -14.875306  ,  16.515192  , ...,   2.4712124 ,
               20.794254  ,   0.16997382], dtype=float32)                 ,
       array([ 37.0768  , -12.805904, -24.864124, ...,  20.78951 ,  25.871597,
               21.257109], dtype=float32)                                     ,
       array([39.19234  ,  2.2530289, 30.183674 , ..., 51.045017 , 28.692915 ,
              26.042522 ], dtype=float32)                                     ,
       array([195.13124  ,  85.83014  , 153.43765  , ...,   4.2165046,
                1.2655593,  -5.8660502], dtype=float32)               ,
       array([66.915054, 52.806072, 52.404675, ..., -2.77463 ,  5.344121,
              -9.447115], dtype=float32)                                 ,
       array([105.56563 ,  54.49863 , 123.5293  , ...,  18.805874,  14.527562,
               22.078308], dtype=float32)                                     ,
       array([161.50537  ,  80.2748   , 129.33846  , ...,  13.617409 ,
               -7.347784 ,   1.5456859], dtype=float32)               ,
       array([ 98.29192   ,  76.31319   ,  58.763325  , ..., -10.407499  ,
                2.814384  ,  -0.25861883], dtype=float32)                 ,
       array([121.341446 ,  26.117912 ,   6.7488284, ..., -41.38278  ,
              -17.570835 , -15.649808 ], dtype=float32)               ,
       array([133.0223   ,  84.67368  ,  96.61394  , ..., -26.676064 ,
                2.3866177, -23.338829 ], dtype=float32)               ,
       array([118.41443  ,  18.035372 ,  49.621895 , ...,   2.4866168,
                3.2989805,  25.205908 ], dtype=float32)               ,
       array([ 88.714066,  29.741196,  26.556957, ..., -27.604446, -20.033888,
              -22.781477], dtype=float32)                                     ,
       array([-22.410734 ,   5.4336796,   4.2411795, ...,  -1.0375835,
               -7.705541 ,  35.159126 ], dtype=float32)               ,
       array([70.69714 , 18.887154,  7.721644, ..., 17.369703, 12.790304,
              18.06103 ], dtype=float32)                                 ,
       array([60.122524, 27.05372 , 20.37373 , ..., 43.677273, 55.08138 ,
              25.561241], dtype=float32)                                 ,
       array([145.05753 ,  20.429499,  58.16358 , ..., -36.535526,  39.01958 ,
               -2.9943  ], dtype=float32)                                     ,
       array([ 10.7662525,   2.037899 ,  31.184877 , ...,  13.822812 ,
              -24.79089  , -19.938263 ], dtype=float32)               ,
       array([45.117744, 11.379687, 42.620064, ..., 12.531982, 38.794643,
              21.431856], dtype=float32)                                 ,
       array([45.23708  , 12.414099 , -1.1504086, ..., 18.361124 , 11.580312 ,
              36.991165 ], dtype=float32)                                     ,
       array([ 17.454653 ,  -5.8044662, -44.222874 , ...,   8.997067 ,
                3.003137 ,  38.77822  ], dtype=float32)               ,
       array([120.36061 ,  40.664852,  46.83704 , ...,  33.370914, -26.109436,
               30.91559 ], dtype=float32)                                     ,
       array([30.564127 , 33.813828 , 11.578891 , ...,  3.4348226, -8.452824 ,
               4.599533 ], dtype=float32)                                     ,
       array([ 62.06665  ,  45.246075 , -21.412271 , ...,  -2.3179762,
               -1.3737955,   5.8981276], dtype=float32)               ,
       array([82.38294  ,  9.991104 , 68.247345 , ..., 14.751661 ,  0.9288387,
              16.122383 ], dtype=float32)                                     ,
       array([ 68.318756  ,  49.317734  ,  44.122692  , ..., -11.27215   ,
               -0.19710156,   6.873884  ], dtype=float32)                 ,
       array([ 43.868378 ,  74.0315   ,  28.058037 , ...,  -8.610584 ,
                4.1679873, -22.118818 ], dtype=float32)               ,
       array([206.31343 , 233.98445 , 192.43242 , ...,  27.32854 ,   8.298529,
              -27.583607], dtype=float32)                                     ,
       array([110.61011  ,  36.367092 ,  95.53954  , ...,   8.555662 ,
                3.7742765,  10.785977 ], dtype=float32)               ,
       array([61.294403 , 61.507763 , 85.985664 , ..., 29.349981 ,  1.7525084,
              10.932927 ], dtype=float32)                                     ,
       array([110.48998 ,  59.11708 ,  86.47618 , ...,   9.650214,   5.718976,
               29.22783 ], dtype=float32)                                     ,
       array([ 72.48707 ,  40.249035,  68.91513 , ..., -37.59265 , -26.66978 ,
              -14.727171], dtype=float32)                                     ,
       array([ 87.45032   ,  43.980507  ,  33.126717  , ...,  -0.60814613,
               -4.230551  , -15.498258  ], dtype=float32)                 ,
       array([70.02197 , 91.50859 , 27.348   , ..., -2.783497, 11.002075,
              16.105396], dtype=float32)                                 ,
       array([110.72128 ,  19.411146,  14.299809, ...,  -9.694554,  19.899492,
               17.00219 ], dtype=float32)                                     ,
       array([92.77664 , 16.845575, 10.594774, ..., 37.99655 , 19.943037,
              20.152779], dtype=float32)                                 ,
       array([124.76796 ,  97.194   ,  55.67973 , ..., -14.128829, -13.111217,
               30.47886 ], dtype=float32)                                     ,
       array([83.281944, 44.332527, 54.789455, ..., 27.02883 , 30.859451,
              14.359209], dtype=float32)                                 ,
       array([80.87196 , 44.986977, 65.09583 , ..., 11.332088, 35.185352,
              25.432268], dtype=float32)                                 ,
       array([-17.183512 ,  69.26789  ,  -5.966991 , ...,   3.2367637,
               26.739996 ,  10.228867 ], dtype=float32)               ,
       array([ 89.18175   ,  47.55677   ,  43.883205  , ...,  31.101473  ,
               -0.93277293, -13.139431  ], dtype=float32)                 ,
       array([104.023994, 122.27158 ,  10.946925, ...,   5.837664, -23.620804,
               -9.597525], dtype=float32)                                     ,
       array([ 42.409817  ,  -0.87746066,  22.2218    , ...,  11.378514  ,
              -21.025135  ,  20.88356   ], dtype=float32)                 ,
       array([ 48.518192,  29.583384, -30.23706 , ..., -15.639634,  26.08138 ,
               15.51039 ], dtype=float32)                                     ,
       array([  8.910029 ,   4.1429253,  35.394794 , ..., -13.113311 ,
              -12.647193 , -31.079805 ], dtype=float32)               ,
       array([51.445374 ,  8.93799  , -1.6077504, ..., -5.614953 , 36.302162 ,
              30.893665 ], dtype=float32)                                     ,
       array([ 78.867035,  64.82197 ,  88.57605 , ...,  -7.826862,  -8.38067 ,
              -14.669364], dtype=float32)                                     ,
       array([235.9463  , 185.06978 , 187.70389 , ...,  -8.228969,   8.052099,
               23.670984], dtype=float32)                                     ,
       array([ 88.36556  ,  99.243576 ,  50.320564 , ...,  40.09635  ,
              -12.309992 ,  -9.7455845], dtype=float32)               ,
       array([ -6.2055535, -10.560891 ,  41.660072 , ..., -42.073868 ,
              -39.791622 , -20.127539 ], dtype=float32)               ,
       array([ 74.31622 ,  41.572308,  21.107656, ...,   6.393596,  -9.725095,
              -15.96325 ], dtype=float32)                                     ,
       array([108.46506 ,  56.067707,  56.868996, ...,  -9.448486, -28.1474  ,
              -10.159643], dtype=float32)                                     ,
       array([106.585014,  99.70483 ,  32.302666, ...,  -4.645703, -37.484383,
              -22.465511], dtype=float32)                                     ,
       array([ 28.132235, -49.493347, -12.813574, ..., -17.277332, -28.34616 ,
               27.553263], dtype=float32)                                     ,
       array([120.29385  ,  76.16499  ,  44.51188  , ...,  -3.6501672,
              -14.589302 ,  -0.8527669], dtype=float32)               ,
       array([ 38.205757  ,  48.010475  , -12.203835  , ...,   0.20209552,
               -4.7419314 ,   8.321297  ], dtype=float32)                 ,
       array([ 28.757858 ,  -4.7559533, -14.290412 , ..., -12.699011 ,
                9.039983 ,  26.367811 ], dtype=float32)               ,
       array([ 69.09791 ,  69.15576 ,  22.79198 , ..., -10.472762,  22.325285,
               32.071964], dtype=float32)                                     ,
       array([157.45042  , 103.333305 , 125.366615 , ..., -16.91541  ,
               39.406525 ,  -7.6825576], dtype=float32)               ,
       array([132.00266 ,  73.420204, 101.45505 , ...,  61.33037 ,   7.574492,
               29.955173], dtype=float32)                                     ,
       array([ 31.332958 , -25.858131 ,  22.650528 , ...,  10.350059 ,
               -5.9388437,  -2.9465895], dtype=float32)               ,
       array([22.684204 , -6.3962035,  5.6856704, ..., 13.161769 , 11.302447 ,
              14.240614 ], dtype=float32)                                     ,
       array([ 33.469963 , -16.591988 ,   2.6586373, ...,  -4.2787027,
              -17.370466 ,  -8.243977 ], dtype=float32)               ,
       array([ 56.814342 ,  20.941055 ,  29.877924 , ...,   2.0451617,
              -15.094584 ,  -3.5929399], dtype=float32)               ,
       array([ 52.710857 ,  10.722162 ,  -1.3449411, ..., -14.118747 ,
               13.517699 ,  20.31187  ], dtype=float32)               ,
       array([46.10004  , 25.265757 , 10.23023  , ...,  4.818645 ,  2.0424538,
               9.667437 ], dtype=float32)                                     ,
       array([60.907433, 56.49487 , 50.783966, ..., 22.451654, 20.851713,
              12.749009], dtype=float32)                                 ,
       array([ -5.050877 , -20.187891 ,  10.322101 , ...,   2.4300132,
               -5.100864 , -12.438675 ], dtype=float32)               ,
       array([58.975975, 66.62455 , 50.755856, ..., 12.166659, 42.586506,
              -5.246193], dtype=float32)                                 ,
       array([26.181381 , 48.18115  , 67.63563  , ..., 48.95368  ,  2.7997363,
              23.74511  ], dtype=float32)                                     ,
       array([ 53.328186,  84.1167  , 115.225845, ...,  47.517334,  49.319935,
               40.012997], dtype=float32)                                     ,
       array([96.29294 , 65.22244 , 36.546844, ..., 50.30496 , 35.216793,
              29.538828], dtype=float32)                                 ,
       array([40.315212 , 82.504585 , 53.326096 , ..., 57.23577  , 40.166725 ,
               4.7601457], dtype=float32)                                     ,
       array([ 82.7822  ,  88.30622 , 150.3951  , ...,  -5.885093, -27.234383,
               50.636696], dtype=float32)                                     ,
       array([27.668526 , 18.715672 ,  3.27956  , ..., 12.722042 , -1.8049005,
               5.6267405], dtype=float32)                                     ,
       array([18.083193 , 40.35836  , -1.0715026, ..., 18.190601 , -4.9851303,
              35.858376 ], dtype=float32)                                     ,
       array([27.05682 , 10.109627, 45.647556, ...,  7.008257,  8.270344,
              14.254159], dtype=float32)                                 ,
       array([131.71973 , 124.05406 , 139.7345  , ...,  23.33143 ,  19.619423,
               25.571474], dtype=float32)                                     ,
       array([33.81815  , 88.488434 ,  7.4707766, ..., 43.73195  , 23.169569 ,
              34.05497  ], dtype=float32)                                     ,
       array([ 85.26463  ,  53.335804 , 114.653046 , ...,   3.9680722,
              -20.276602 ,  45.306984 ], dtype=float32)               ,
       array([ 9.2365417e+01,  5.4643089e+01,  8.4926125e+01, ...,
              -8.4810343e+00,  6.9855156e+00, -6.2754087e-02], dtype=float32),
       array([94.62589  , 91.17571  , 86.5142   , ..., -5.8618526, 24.008743 ,
              27.914202 ], dtype=float32)                                     ,
       array([153.75491 , 155.185   ,  97.85079 , ..., -14.766303, -18.909513,
              -35.04201 ], dtype=float32)                                     ,
       array([94.66275  , 45.528778 , 71.88086  , ..., 58.19792  ,  1.0117581,
              13.298099 ], dtype=float32)                                     ,
       array([33.73609  , 28.15363  , -2.4107776, ...,  3.88549  , 16.321362 ,
              36.210194 ], dtype=float32)                                     ,
       array([ 23.095268,  42.449345, -14.821094, ...,  17.161959,  37.847   ,
               -3.399404], dtype=float32)                                     ,
       array([16.757992 ,  3.8130858, 20.28385  , ...,  1.5646784, 11.798494 ,
              25.01572  ], dtype=float32)                                     ,
       array([70.52734 , 52.02745 , 48.04374 , ..., 28.115744, 28.048683,
              41.59731 ], dtype=float32)                                 ,
       array([153.16733 , 127.52866 ,  98.0859  , ..., -14.337296, -18.943518,
               17.642067], dtype=float32)                                     ,
       array([ 86.299965, 150.54161 , 153.79066 , ...,  40.71366 ,  14.782925,
                9.725669], dtype=float32)                                     ,
       array([104.84579 ,  25.182096,  32.07803 , ...,  16.808084,  29.532331,
              -11.737584], dtype=float32)                                     ,
       array([ 61.21843  ,  23.477224 ,   3.0196688, ...,   7.8085055,
                5.396643 , -21.950901 ], dtype=float32)               ,
       array([39.974865, 59.096676, 19.83555 , ...,  8.556257, 10.60343 ,
              31.423698], dtype=float32)                                 ,
       array([ 40.5229  ,  33.799927, -17.995655, ...,  -4.005654,  -4.151723,
               49.052425], dtype=float32)                                     ,
       array([  6.2670984,  50.55069  ,  50.968296 , ...,  31.9184   ,
              -31.984663 , -19.293997 ], dtype=float32)               ,
       array([113.200356 ,  81.49285  ,  56.860123 , ...,  11.20568  ,
                3.5601025,  22.987206 ], dtype=float32)               ,
       array([167.93301, 157.79482, 185.23804, ..., 199.06767, 343.04337,
              327.02734], dtype=float32)                                 ,
       array([ 44.909737,  27.613176,  33.958088, ..., -15.23075 , -11.526373,
               13.611096], dtype=float32)                                     ,
       array([-34.684093,  29.98306 , -11.529915, ...,  21.642508,  -5.79858 ,
               18.590199], dtype=float32)                                     ,
       array([49.765038, 11.173132, 23.717337, ..., 26.429712, 39.483166,
              51.99511 ], dtype=float32)                                 ,
       array([ 64.23038 ,  61.757492, 118.38212 , ..., -11.654596,  37.840805,
               24.139463], dtype=float32)                                     ,
       array([133.05313 , 113.36483 , 156.96944 , ...,  34.420372, -22.835106,
               27.288614], dtype=float32)                                     ,
       array([-20.002766, -24.864729,  19.925062, ...,  43.959843, -33.84462 ,
                8.006851], dtype=float32)                                     ,
       array([ 38.90917  ,  89.34818  ,  76.65898  , ...,  -6.921184 ,
              -15.275598 ,   3.1818733], dtype=float32)               ,
       array([ 33.69449  ,  42.290714 ,  23.981697 , ...,   7.9695344,
              -13.5135765, -34.25045  ], dtype=float32)               ,
       array([ 16.171621 , -21.954124 , -41.83816  , ..., -19.756979 ,
              -15.338389 ,   0.5003567], dtype=float32)               ,
       array([-50.00005  , -15.791339 ,   6.7609878, ..., -18.562782 ,
                6.6519895,  -7.9451222], dtype=float32)               ,
       array([133.85365  ,  89.125    ,  67.10068  , ...,  -1.3721178,
                7.3240614,  36.45526  ], dtype=float32)               ,
       array([48.511723, 47.346416, 37.07621 , ..., 32.146996, 16.21911 ,
              31.063515], dtype=float32)                                 ,
       array([104.95351 ,  93.18255 ,  40.908276, ...,   5.34017 ,   9.157477,
              -23.638329], dtype=float32)                                     ,
       array([ 15.141929,  45.379448,  50.97214 , ...,   6.265083, -26.141747,
               26.413471], dtype=float32)                                     ,
       array([109.881386 ,  77.94508  ,  88.58007  , ..., -22.029163 ,
                3.4502983,   2.3009698], dtype=float32)               ,
       array([ 78.75392  ,  70.16429  ,  46.54025  , ..., -44.316883 ,
               -5.9063888,  -0.19815  ], dtype=float32)               ,
       array([272.73294  , 228.61435  , 223.52737  , ...,  23.104937 ,
                1.8341583,   7.3601623], dtype=float32)               ,
       array([119.317955 ,  85.472466 , 116.517    , ...,  30.453571 ,
                2.4705594, -13.97096  ], dtype=float32)               ,
       array([ 64.11343 ,  68.93868 ,  84.684845, ..., -21.553085,   9.977516,
               15.55432 ], dtype=float32)                                     ,
       array([ 55.755314 ,  78.463974 ,  90.1513   , ..., -45.29112  ,
               -3.646007 ,  -3.3183699], dtype=float32)               ,
       array([113.72207 , 115.59155 ,  48.824913, ..., -33.64419 , -29.569777,
              -26.56202 ], dtype=float32)                                     ,
       array([ 34.024364 , 132.06882  , 139.71825  , ...,   7.204264 ,
                6.4817367,  30.098501 ], dtype=float32)               ,
       array([ 45.379482 ,  65.520386 , 145.67708  , ..., -30.56744  ,
              -14.5054655, -42.880383 ], dtype=float32)               ,
       array([105.40306 ,  50.222874,  89.495674, ...,  27.371778,  76.22542 ,
              -25.812622], dtype=float32)                                     ,
       array([ 34.56831   ,  14.983641  ,  43.812332  , ...,  -0.22134231,
              -22.92371   ,  48.71775   ], dtype=float32)                 ,
       array([42.048714  , 55.086304  ,  0.28055957, ..., -6.964897  ,
               9.510686  , -0.0807655 ], dtype=float32)               ,
       array([164.38943 , 120.94816 ,  96.60563 , ...,  16.524841,  22.13588 ,
               43.971348], dtype=float32)                                     ,
       array([149.22537  , 124.4336   ,  89.3001   , ...,  20.698229 ,
               -1.8736075,  15.687499 ], dtype=float32)               ,
       array([139.34398  , 120.25991  , 132.28426  , ..., -14.017559 ,
              -14.124834 ,   4.6535945], dtype=float32)               ,
       array([ 25.61402 ,  49.2072  ,  73.741295, ...,  16.776463, -46.42185 ,
              -20.202812], dtype=float32)                                     ,
       array([ 53.531414,  72.5913  ,  36.79721 , ..., -28.467285,   3.875391,
               12.759032], dtype=float32)                                     ,
       array([ 31.08854 ,  32.525215,  46.45776 , ..., -21.14295 ,  22.037376,
               20.833996], dtype=float32)                                     ,
       array([ 42.837097,  35.61789 ,  36.728798, ...,  40.930405, -27.197748,
               15.377942], dtype=float32)                                     ,
       array([ 85.17219 ,  79.25153 ,  68.22528 , ..., -40.538696,  20.989075,
              -26.083584], dtype=float32)                                     ,
       array([124.19375 , 116.957726,  62.566196, ..., -17.432722, -36.68937 ,
              -11.637607], dtype=float32)                                     ,
       array([157.33652  , 146.06621  ,  44.95692  , ...,  -2.6518757,
              -20.129633 ,  13.6532755], dtype=float32)               ,
       array([124.355736 ,  91.77634  ,  59.93606  , ...,   9.103567 ,
                3.0855362, -16.306353 ], dtype=float32)               ,
       array([ 97.60666 , 164.81967 , 170.41864 , ...,  20.38121 ,  -9.255015,
               73.96362 ], dtype=float32)                                     ,
       array([135.27182  , 122.828926 ,  23.43318  , ...,   2.5473015,
              -29.367155 , -27.946903 ], dtype=float32)               ,
       array([77.2528  , 78.68658 , 35.55612 , ...,  7.528232, 47.91317 ,
              19.679668], dtype=float32)                                 ,
       array([132.50148 , 148.15659 ,  97.526245, ...,  18.485723,  17.214705,
               37.55034 ], dtype=float32)                                     ,
       array([16.636929 , 16.773298 , -1.4068229, ..., 17.39094  ,  4.5934477,
              -7.696456 ], dtype=float32)                                     ,
       array([ 22.002634, -11.301712,  32.43831 , ...,  16.271404,  23.959843,
               51.673183], dtype=float32)                                     ,
       array([ 22.716522 , -29.739069 ,  -4.1743155, ...,  45.90264  ,
               41.17347  ,   8.365578 ], dtype=float32)               ,
       array([60.99939  , 73.78005  , 56.279163 , ..., -2.2504303, -5.048994 ,
              15.950546 ], dtype=float32)                                     ,
       array([-17.95675 , -21.487589,  -8.940639, ...,  50.73241 ,  13.36443 ,
              -19.564491], dtype=float32)                                     ,
       array([99.784065, 65.50208 , 44.20786 , ..., 18.514578, -3.337776,
               8.086164], dtype=float32)                                 ,
       array([67.74645  , 49.62862  , 29.67971  , ...,  9.43898  ,  6.5832305,
              18.06092  ], dtype=float32)                                     ,
       array([175.91286 , 110.711266,  91.27182 , ..., -14.43156 ,  -7.881587,
               -7.61844 ], dtype=float32)                                     ,
       array([ 66.72461 ,   9.865089, -31.657688, ...,  22.880527,  33.269974,
               38.892292], dtype=float32)                                     ,
       array([ 98.58727  , 100.36731  ,  81.13315  , ...,  -8.910835 ,
              -11.684186 ,  -4.2893605], dtype=float32)               ,
       array([42.610195, 34.291176, 41.31934 , ..., 18.778242, 71.39434 ,
              35.223175], dtype=float32)                                 ,
       array([105.65836  ,  68.18862  ,  72.75168  , ...,  -4.1367745,
               15.56284  ,  -8.257013 ], dtype=float32)               ,
       array([108.65394 , 110.301575,  86.12295 , ...,  19.271845,  28.932034,
               28.283669], dtype=float32)                                     ,
       array([ 65.54617  ,   7.1871414, -18.661331 , ...,  10.8808155,
               11.479538 ,  13.863609 ], dtype=float32)               ,
       array([ 12.071566  , -13.996367  ,  -1.3861504 , ...,  -2.7514954 ,
                0.4055102 ,  -0.86250645], dtype=float32)                 ,
       array([174.37593 , 134.02084 , 127.67722 , ..., -12.866384, -35.996536,
                0.93194 ], dtype=float32)                                     ,
       array([ 43.448387,  27.370884,  10.597509, ..., -21.07989 ,  38.52973 ,
               24.68798 ], dtype=float32)                                     ,
       array([106.941124, 120.3071  ,  70.87219 , ...,  69.77831 ,  85.70278 ,
               93.90132 ], dtype=float32)                                     ,
       array([ 63.58876 ,  -1.47404 , -32.283108, ...,  18.077284,  18.2995  ,
               10.086709], dtype=float32)                                     ,
       array([ 80.37028 ,  56.37878 ,  59.543945, ..., -26.213264, -14.57717 ,
               10.625186], dtype=float32)                                     ,
       array([117.880165, 113.312065, 149.28346 , ...,  -7.567905,  -8.056205,
               -9.980382], dtype=float32)                                     ,
       array([73.262924,  3.321896, 61.760456, ..., 66.94633 ,  9.814309,
              39.88783 ], dtype=float32)                                 ,
       array([  5.3420267,  13.708056 ,  40.610855 , ..., -10.084332 ,
               59.818886 , -24.442104 ], dtype=float32)               ,
       array([14.433982 , 20.933598 , 13.375719 , ...,  8.796807 , 36.79589  ,
               0.8238092], dtype=float32)                                     ,
       array([282.9877  , 114.01492 , 121.043304, ...,  65.54298 ,  53.023327,
               47.996895], dtype=float32)                                     ,
       array([20.137747, -3.976677, 61.711536, ..., 57.33044 , 41.496056,
              29.958862], dtype=float32)                                 ,
       array([1030.1118  ,  980.8866  ,  780.4531  , ...,   -3.605278,
               -37.72198 ,   62.63571 ], dtype=float32)               ,
       array([ 45.00792  ,  70.10152  ,  67.45168  , ...,  -0.5935817,
              -23.569841 ,  -6.841048 ], dtype=float32)               ,
       array([38.384106 ,  3.1766877, 46.046177 , ..., 12.30807  , 14.192408 ,
              21.100624 ], dtype=float32)                                     ,
       array([158.95592 ,  33.563095, -12.101412, ...,  47.336857,  30.524137,
               46.238804], dtype=float32)                                     ,
       array([74.83398  , 46.252537 , 29.761742 , ..., 13.951614 , -5.831596 ,
               1.6383815], dtype=float32)                                     ,
       array([130.94931 ,  16.463387,  65.64096 , ...,  13.962109, -19.528473,
               16.147778], dtype=float32)                                     ,
       array([ 65.615036  , -56.120678  ,  -2.9886608 , ...,  -0.67234457,
               69.675415  ,  48.15423   ], dtype=float32)                 ,
       array([ 26.198877, -39.662518,   8.145092, ...,  61.35136 ,  23.309946,
               26.099089], dtype=float32)                                     ,
       array([126.46917 ,  42.59384 ,  68.94535 , ...,  55.52029 ,  28.163778,
               66.83242 ], dtype=float32)                                     ,
       array([ 28.779282 ,   1.4521858, -15.658867 , ...,  29.599007 ,
               26.995832 ,   9.378323 ], dtype=float32)               ,
       array([ 82.068695,  18.788141,  75.53926 , ...,  26.894459, -16.58245 ,
              -30.073284], dtype=float32)                                     ,
       array([496.9459  , 225.8657  , 155.18997 , ...,  17.122643, -26.704338,
               42.316574], dtype=float32)                                     ,
       array([ 96.14958 ,  76.20624 ,  66.57022 , ..., -45.80942 , -51.75789 ,
              -59.417652], dtype=float32)                                     ,
       array([ -4.974003, -22.187265, -11.215234, ...,  37.546608,  49.105118,
               45.42471 ], dtype=float32)                                     ,
       array([-46.362934 ,  17.130547 , -13.32363  , ...,  -2.7834678,
               10.066894 ,  -5.0996757], dtype=float32)               ,
       array([34.332054 , 17.030802 , -1.2167103, ..., -1.7793081, 37.342735 ,
              31.554459 ], dtype=float32)                                     ,
       array([60.64542 , 56.44086 , 71.19067 , ..., 45.680435, 17.068655,
              40.86666 ], dtype=float32)                                 ,
       array([ 76.98332  ,  12.524115 ,  -4.3622828, ...,   6.3379164,
              -12.804084 , -28.588165 ], dtype=float32)               ,
       array([35.91598 , 38.767227,  6.370654, ..., 37.926247, 38.389282,
              32.177044], dtype=float32)                                 ,
       array([110.800545, 112.30479 ,  89.79639 , ..., -44.049644, -30.212358,
               62.582375], dtype=float32)                                     ,
       array([  7.625426  ,  -0.18604892, -16.092297  , ...,  20.433886  ,
               32.746174  ,  29.538872  ], dtype=float32)                 ,
       array([101.852585, 124.98547 ,  62.21357 , ..., -16.645145,  -5.808575,
               61.42316 ], dtype=float32)                                     ,
       array([89.43141  , 41.41786  , -5.1470523, ..., 34.772423 , -4.5371513,
              38.77321  ], dtype=float32)                                     ,
       array([49.545288 , 61.715576 , 60.523075 , ..., 10.328356 , -5.4963684,
              34.74678  ], dtype=float32)                                     ,
       array([ 77.890816  ,  10.795494  ,   0.10374103, ..., -11.002125  ,
                0.74323565,  -5.4626064 ], dtype=float32)                 ,
       array([ 41.60516  ,  26.678455 ,  -1.4864962, ...,  -8.949832 ,
              -19.000284 ,  18.474236 ], dtype=float32)               ,
       array([108.7909   ,  56.60434  ,  45.37121  , ...,   2.2656507,
               39.311584 ,  28.308554 ], dtype=float32)               ,
       array([  3.3653827,  12.241132 , -12.440528 , ...,   0.4512185,
                1.1042079,  14.3484745], dtype=float32)               ,
       array([ 21.745205 , -29.518314 ,  -6.984918 , ...,  35.72104  ,
               53.392735 , -11.9602165], dtype=float32)               ,
       array([ 68.0421  ,  -7.198441, -11.540219, ...,  22.502905,   7.194319,
               46.20945 ], dtype=float32)                                     ,
       array([ 14.629332,  38.673176, -11.443754, ...,  51.047977,   7.514555,
               63.326805], dtype=float32)                                     ,
       array([115.42447 , 123.837234, 110.20754 , ...,   6.895171,  54.570328,
               77.467   ], dtype=float32)                                     ,
       array([106.75473  ,   7.8356314,  15.213787 , ..., -13.173706 ,
               25.517982 ,  19.313364 ], dtype=float32)               ,
       array([122.570114 ,  76.58173  , 110.662384 , ...,  -6.7603188,
                3.017389 ,  15.268992 ], dtype=float32)               ,
       array([ 90.91158  ,  33.70345  , -21.44143  , ...,  -7.6001596,
              -11.899545 ,  55.066387 ], dtype=float32)               ,
       array([109.98621 ,  63.508327,  82.53104 , ...,  22.420849,  36.757244,
               16.287422], dtype=float32)                                     ,
       array([137.3837  ,  95.92318 , 148.76196 , ...,  23.572933,  26.339811,
               47.03833 ], dtype=float32)                                     ,
       array([112.507805 ,  93.919334 ,  43.86624  , ...,  44.403217 ,
               -1.8829418,  10.454918 ], dtype=float32)               ,
       array([ 86.77179  , 107.04357  , 106.344444 , ...,  -6.6459446,
              -16.275017 , -20.821898 ], dtype=float32)               ,
       array([ 68.99612  ,  98.88181  , 137.4552   , ...,  10.378276 ,
               -2.9788296,   8.471833 ], dtype=float32)               ,
       array([136.18344  , 248.10994  , 189.91068  , ...,   1.3724672,
               29.05232  ,   3.1817062], dtype=float32)               ,
       array([126.04197  ,  25.768026 , 106.35774  , ...,  16.027271 ,
                3.9019086,  10.76449  ], dtype=float32)               ,
       array([ 98.5568    ,  12.719248  ,  -3.0585294 , ..., -57.69399   ,
               -4.5081835 ,   0.38602245], dtype=float32)                 ,
       array([ 39.844505, -28.812075,  29.170341, ...,  -8.839466,  -6.192053,
              -28.652899], dtype=float32)                                     ,
       array([133.59183 , 172.51324 ,  82.63059 , ...,  18.706108,  34.59313 ,
               32.531033], dtype=float32)                                     ,
       array([ 25.650389 ,  -1.9664857,  23.632366 , ...,  21.243095 ,
               34.49151  , -19.909634 ], dtype=float32)               ,
       array([ 68.40261  ,   4.1547923,  52.802986 , ...,  16.101147 ,
              -14.967826 , -39.8129   ], dtype=float32)               ,
       array([139.09132 ,  84.64926 , 100.30137 , ...,  40.822445,  23.562622,
               79.61648 ], dtype=float32)                                     ,
       array([47.95062 , 22.768036, 36.670887, ..., 40.7102  , 28.908657,
              41.281586], dtype=float32)                                 ,
       array([ 26.197039 , -45.782524 , -30.216753 , ...,  -3.8371296,
               -6.343991 , -40.69964  ], dtype=float32)               ,
       array([ 23.344435 ,  17.930424 ,  39.85921  , ...,  -1.1306973,
              -41.259716 ,  40.47689  ], dtype=float32)               ,
       array([129.56116 ,  52.15536 , 109.836685, ...,  -5.093879, -81.542076,
              -15.605944], dtype=float32)                                     ,
       array([ 81.728645 ,  88.744514 ,  99.47336  , ...,   6.3377576,
              -52.08337  ,  30.15016  ], dtype=float32)               ,
       array([ 40.5799  ,  35.156315, -20.871151, ...,  -9.455501,  -8.209816,
              -21.846378], dtype=float32)                                     ,
       array([49.379032, -8.09678 , -3.567316, ..., 12.79733 ,  8.564194,
              30.783617], dtype=float32)                                 ,
       array([-23.955109  ,  -0.86116624,  21.980911  , ...,  -4.6222496 ,
                5.071673  ,  64.47828   ], dtype=float32)                 ,
       array([ 30.443829,  81.03683 ,  55.55759 , ...,  10.894181,   6.414945,
              -11.570231], dtype=float32)                                     ,
       array([50.29781 , 24.644598, 32.531124, ..., 29.456507, 81.21843 ,
              62.60541 ], dtype=float32)                                 ,
       array([-32.422974 ,   0.6290473,  21.521872 , ..., -24.688019 ,
              -23.1531   , -32.583878 ], dtype=float32)               ,
       array([66.779305 , 70.105965 ,  3.233191 , ..., -1.032225 , 34.917774 ,
              -6.7953386], dtype=float32)                                     ,
       array([ 59.996334 ,  -2.922262 , -17.089985 , ...,  26.710157 ,
                1.0176568,  37.684235 ], dtype=float32)               ,
       array([ -2.3855965, -51.202522 ,  -2.69107  , ...,  70.84834  ,
               -2.2277486,  25.64413  ], dtype=float32)               ,
       array([ 18.912207, -10.317416, -41.590263, ...,  46.882236,  25.86892 ,
              -10.630154], dtype=float32)                                     ,
       array([11.539084 , 84.26196  ,  4.2565675, ..., -2.8090193, -7.342223 ,
              61.65155  ], dtype=float32)                                     ,
       array([ 44.284706,  10.328801,  51.540474, ..., -64.528534, -34.85784 ,
              -32.238667], dtype=float32)                                     ,
       array([ 21.640478, -39.34124 ,   2.212209, ...,  -8.816599, -18.5542  ,
               18.32376 ], dtype=float32)                                     ,
       array([-1.2190403e-02, -6.3129382e+00, -2.2911129e+01, ...,
              -9.2751181e-01,  2.5386940e+01,  1.7394728e+01], dtype=float32),
       array([121.113174  , 110.97329   , 237.28401   , ...,   0.67492044,
              -10.495742  ,   6.649436  ], dtype=float32)                 ,
       array([-23.95306 ,  19.840439, -23.849329, ...,  63.9422  ,  30.770863,
               39.37214 ], dtype=float32)                                     ,
       array([ 62.452297, -34.37864 , -29.3842  , ..., -13.507882, -35.7286  ,
              -25.025764], dtype=float32)                                     ,
       array([114.56742 ,  43.207592,  79.10671 , ...,  63.85689 ,  75.03774 ,
               72.26308 ], dtype=float32)                                     ,
       array([75.89263  , 52.979656 , -4.0846004, ..., 87.55766  , 97.81799  ,
              63.1558   ], dtype=float32)                                     ,
       array([ 15.65352 ,  30.67085 , -24.197369, ...,   4.225737,  30.92986 ,
               41.144287], dtype=float32)                                     ,
       array([58.394   , 85.93384 , 29.654743, ..., 62.709072, -3.20404 ,
              65.31744 ], dtype=float32)                                 ,
       array([115.76107 ,  12.95802 ,  47.05477 , ..., -28.84363 ,  29.549196,
               30.058346], dtype=float32)                                     ,
       array([118.00105  ,  99.00753  ,  39.03161  , ...,   4.5956645,
               28.927729 , -19.359503 ], dtype=float32)               ,
       array([60.29696 , 48.672333, 53.6252  , ..., 24.022142, 46.62648 ,
              72.386826], dtype=float32)                                 ,
       array([  0.98834115, -49.856174  ,  41.716     , ..., -28.214527  ,
              -42.776676  ,  16.91918   ], dtype=float32)                 ,
       array([184.402   ,  87.60055 ,  36.42499 , ...,   6.806196,  30.54793 ,
               35.154137], dtype=float32)                                     ,
       array([ -3.7057137, -16.336193 ,  15.367186 , ..., 355.1977   ,
              298.9943   , 291.79443  ], dtype=float32)               ,
       array([ -1.3177904, -19.342466 , -19.228992 , ...,  -4.5505257,
               18.028448 ,  -6.327418 ], dtype=float32)               ,
       array([ 59.677998, 157.30206 ,  96.40619 , ...,  40.772903, -14.536325,
               42.9045  ], dtype=float32)                                     ,
       array([ 80.02479  ,   4.6804376, -20.813473 , ...,  58.828495 ,
               66.824104 ,  49.90996  ], dtype=float32)               ,
       array([ 76.764275,  59.818874,   8.614109, ..., -12.687641, -22.526175,
               -6.462732], dtype=float32)                                     ,
       array([206.84126  ,  38.766655 , 109.54071  , ...,  20.181398 ,
               -7.1683826,  85.884605 ], dtype=float32)               ,
       array([103.44868 ,  75.218864,  53.723824, ..., -16.600018,  13.379003,
               24.18946 ], dtype=float32)                                     ,
       array([161.3854   , 161.87674  ,  76.03695  , ...,   9.127612 ,
               -5.3839126,  18.941366 ], dtype=float32)               ,
       array([124.12251  ,  90.86967  ,  73.15283  , ...,  -8.874397 ,
                3.6414173, -24.511988 ], dtype=float32)               ,
       array([128.19049  , 174.9081   ,  39.400154 , ...,  -1.3891184,
               22.506216 ,  21.83929  ], dtype=float32)               ,
       array([46.951553, 65.70357 , 57.086853, ..., 15.966877, 16.557917,
              58.975735], dtype=float32)                                 ,
       array([40.115402 , 54.775383 , 54.23645  , ..., 11.514095 ,  4.4808736,
              34.068985 ], dtype=float32)                                     ,
       array([ 58.40174  ,   7.9772954,  28.990656 , ...,   3.662454 ,
               -1.4670904, -35.42288  ], dtype=float32)               ,
       array([43.824562 , 55.599773 , 93.283005 , ..., -2.1243534, -6.2169085,
              57.96186  ], dtype=float32)                                     ,
       array([ 79.240685, 125.2214  , 166.37308 , ...,  38.91084 , 113.73408 ,
               64.24347 ], dtype=float32)                                     ,
       array([-51.69471 , -48.05496 ,  -6.238637, ..., -49.775536, -34.393047,
              -12.667548], dtype=float32)                                     ,
       array([-5.854559, 40.26478 , 71.91387 , ..., 34.394123, 40.403805,
              26.403646], dtype=float32)                                 ,
       array([106.99298 , 121.8535  ,  84.652245, ...,  14.955463,   0.278759,
               29.551243], dtype=float32)                                     ,
       array([325.81705  , 347.12405  , 264.1404   , ..., -12.366158 ,
                1.6256083,  47.004925 ], dtype=float32)               ,
       array([ 60.954998 ,  31.354454 , -23.65943  , ..., -10.6828165,
               17.584496 ,  17.428389 ], dtype=float32)               ,
       array([80.76036 , 46.995853, 32.998344, ..., 25.247053, 24.72095 ,
              38.55709 ], dtype=float32)                                 ,
       array([ 57.21983   ,  28.900932  ,   5.9092135 , ..., -13.230629  ,
              -12.073519  ,   0.06775343], dtype=float32)                 ,
       array([ 57.9282  ,  49.738827, 103.64114 , ..., -20.882639,  15.031132,
              -33.411003], dtype=float32)                                     ,
       array([ 41.201336  ,  55.247692  , 125.30507   , ...,  40.35249   ,
               -0.83831096,  49.287106  ], dtype=float32)                 ,
       array([108.18673  ,  80.494446 ,  54.067287 , ...,   1.435524 ,
               -2.7476838,  21.361757 ], dtype=float32)               ,
       array([237.669   , 112.06154 , 142.08655 , ..., -16.216026, -16.213423,
              -19.656635], dtype=float32)                                     ,
       array([ 28.101208  , -35.936752  ,  14.058266  , ...,  14.527226  ,
               42.983494  ,   0.21506068], dtype=float32)                 ,
       array([116.53113  ,  65.799675 ,  14.235068 , ...,   6.5845623,
               31.899427 ,  25.074394 ], dtype=float32)               ,
       array([ 14.84813 ,  39.64566 ,  36.42868 , ..., -19.503736,  33.687115,
               28.76964 ], dtype=float32)                                     ,
       array([30.701752 , 42.956207 , -2.6014233, ..., 32.189884 , 40.535183 ,
              49.050564 ], dtype=float32)                                     ,
       array([ -7.5327168,  12.160338 , -13.315258 , ..., -21.417189 ,
                4.3943105,  11.573296 ], dtype=float32)               ,
       array([39.337902, 62.26476 , 75.40785 , ..., 50.53369 , 24.24352 ,
              29.571983], dtype=float32)                                 ,
       array([ 19.710848 , -41.471203 , -13.2312765, ...,   3.3798163,
               13.22497  ,  51.939636 ], dtype=float32)               ,
       array([130.65652  , 113.99321  ,  34.97236  , ...,   3.8362186,
               -9.070721 , -16.398039 ], dtype=float32)               ,
       array([100.46639 ,  88.224625,   9.426378, ...,  40.757538,  31.033457,
               37.431866], dtype=float32)                                     ,
       array([ 67.99695  ,  45.59686  , 117.89902  , ...,  25.219797 ,
               12.333754 ,   1.2832373], dtype=float32)               ,
       array([100.92053 , 130.99886 , 166.41913 , ...,  28.6243  ,  31.95243 ,
               38.612606], dtype=float32)                                     ,
       array([119.38237 ,  81.451164, -10.333327, ...,   2.758198,  -7.03614 ,
               48.164833], dtype=float32)                                     ,
       array([48.48864 , 20.540306, 49.95179 , ..., 36.818386, 10.943471,
              20.57199 ], dtype=float32)                                 ,
       array([ 71.92143 ,  27.827488, 121.20353 , ...,  38.70867 , -13.425002,
               29.9528  ], dtype=float32)                                     ,
       array([43.28724 , 29.515213, 26.95053 , ..., 14.502231,  8.721379,
              28.210222], dtype=float32)                                 ,
       array([26.776747  , 21.33037   , 43.07099   , ..., 24.487663  ,
               0.12759672, -6.3552904 ], dtype=float32)               ,
       array([43.357307, 11.439277, 13.976952, ..., 25.454199, 15.269275,
              47.919006], dtype=float32)                                 ,
       array([ 78.11398 , 101.251114, 102.22995 , ...,  12.350644,  25.537058,
               48.148273], dtype=float32)                                     ,
       array([100.00196  ,  45.133945 ,  24.946379 , ..., -14.612354 ,
              -28.36441  ,  -7.9822073], dtype=float32)               ,
       array([ 99.21157  ,  20.702877 ,  60.509636 , ..., -13.711537 ,
                3.2277124,   9.270292 ], dtype=float32)               ,
       array([ 96.761086  , -22.820654  ,   6.9523    , ...,  -8.141853  ,
               -8.738343  ,   0.71418315], dtype=float32)                 ,
       array([68.29123  , 30.098783 ,  8.124104 , ..., -9.953464 , -3.2520053,
              24.310644 ], dtype=float32)                                     ,
       array([64.89854 , 22.229982, 29.74469 , ..., 47.123913, 69.52255 ,
              63.991467], dtype=float32)                                 ,
       array([59.052444 , 22.234774 ,  6.8632364, ...,  5.5614467, 28.648987 ,
              -2.5871572], dtype=float32)                                     ,
       array([  4.714474 ,  74.27105  ,  32.031387 , ...,  51.47795  ,
              -18.985905 ,   6.6847243], dtype=float32)               ,
       array([76.036446 , 46.288826 , -5.0629573, ...,  7.7813582, 23.755001 ,
              11.599381 ], dtype=float32)                                     ,
       array([ 38.234447, -19.218596,  39.138702, ...,  14.257372, -18.217012,
              -22.541807], dtype=float32)                                     ,
       array([-8.723199, 20.715511, 42.718433, ..., 16.805265, 24.539875,
              10.191714], dtype=float32)                                 ,
       array([70.5967  , 44.417957, 77.41951 , ...,  3.497371, 42.340523,
              71.1179  ], dtype=float32)                                 ,
       array([ 75.593956 ,  65.16042  ,  88.203674 , ..., -17.70723  ,
               -2.7536526,  12.768736 ], dtype=float32)               ,
       array([ -2.6334307, -13.1003475,  25.850649 , ...,  -3.553602 ,
                4.4820213,  11.690897 ], dtype=float32)               ,
       array([42.127003 , 24.06413  , 25.821522 , ...,  2.5170922,  1.8855797,
               1.9542722], dtype=float32)                                     ,
       array([58.086765, 23.779772, 47.5237  , ..., 11.907644, 18.25496 ,
              24.309675], dtype=float32)                                 ,
       array([ 72.38945 ,  31.954533,  35.46369 , ..., -10.249667, -16.023006,
               27.165817], dtype=float32)                                     ,
       array([-106.98459  , -120.10923  ,  431.7519   , ...,    4.5114884,
                61.588375 ,    5.864098 ], dtype=float32)                 ,
       array([123.15487  , 109.42052  ,  65.706    , ...,   5.2877936,
               25.434729 ,  57.161335 ], dtype=float32)               ,
       array([ 59.965557 ,  40.18299  ,  20.441244 , ..., -20.50097  ,
               -5.6457067,   6.0677447], dtype=float32)               ,
       array([25.39954 , 45.98728 , 24.26207 , ..., 30.046774, 20.259043,
              59.096497], dtype=float32)                                 ,
       array([69.239525, 78.003716, 77.138084, ..., 25.750923,  7.120734,
              28.88275 ], dtype=float32)                                 ,
       array([ 36.31656  ,  12.099432 ,  74.85471  , ...,  -5.238136 ,
               -0.1871349, -15.7159   ], dtype=float32)               ,
       array([  5.7002153, -48.396614 ,  24.97285  , ...,  25.846664 ,
               23.799988 ,  31.893925 ], dtype=float32)               ,
       array([330.82022, 176.19446, 200.9064 , ..., 140.1819 , 147.18802,
              141.16   ], dtype=float32)                                 ,
       array([ 33.876717, -10.813565, -11.098931, ...,  20.690264,  29.513756,
               21.873346], dtype=float32)                                     ,
       array([47.810596, 13.080462, 35.86434 , ..., 55.887177, 14.00556 ,
              44.542725], dtype=float32)                                 ,
       array([17.192295  , 51.882557  ,  0.37135446, ..., 33.684788  ,
              28.34252   , 37.73443   ], dtype=float32)               ,
       array([ 17.711315,  73.68319 ,  27.467318, ..., -22.03407 ,  40.758553,
              -14.05209 ], dtype=float32)                                     ,
       array([175.21788 , 174.0086  , 218.68466 , ...,  20.458727,   8.300493,
               18.97852 ], dtype=float32)                                     ,
       array([136.19019  ,  88.09276  ,  98.77717  , ...,  -2.3949533,
              -14.143853 ,   7.091412 ], dtype=float32)               ,
       array([73.41861 , 21.028307, 44.776005, ...,  8.080811, 52.38442 ,
              56.477287], dtype=float32)                                 ,
       array([90.41686  , 88.223656 , 24.646002 , ..., 18.117744 ,  2.2793891,
              42.726643 ], dtype=float32)                                     ,
       array([-13.03471  ,  31.05707  ,  15.4052515, ...,  13.510451 ,
               13.133295 ,  51.658314 ], dtype=float32)               ,
       array([133.68736 , 112.228096,  69.1767  , ..., -24.331465,  -7.896012,
              -17.585691], dtype=float32)                                     ,
       array([ 77.13613 ,  14.810299,  28.049625, ..., -10.871936,  26.385994,
               33.568344], dtype=float32)                                     ,
       array([101.00721 ,  59.429127, 108.44532 , ...,  35.44174 ,  27.424599,
              -17.732237], dtype=float32)                                     ,
       array([ 67.18344 ,  67.74126 , 104.05215 , ...,  13.14186 , -20.6593  ,
               -7.530831], dtype=float32)                                     ,
       array([ 73.15871  ,  50.318775 ,  42.727535 , ..., -31.666119 ,
               20.513357 ,  -2.6553922], dtype=float32)               ,
       array([72.87559 , 95.119576, 32.433506, ..., 27.698963, 20.805872,
              18.668013], dtype=float32)                                 ,
       array([  7.8432713,  20.744352 ,  -5.7742124, ..., -59.152065 ,
              -16.283684 ,   0.8741398], dtype=float32)               ,
       array([67.187294, 24.613565, 19.039267, ..., 23.606321, -3.417026,
              19.71134 ], dtype=float32)                                 ,
       array([123.90319   ,  93.93908   ,  93.490265  , ...,   0.56890744,
              -23.919552  ,  45.132664  ], dtype=float32)                 ,
       array([ -0.15754032,   7.7858863 , -18.863762  , ...,  -6.051735  ,
               16.332176  ,  37.70643   ], dtype=float32)                 ,
       array([127.47097  ,  47.274902 ,  41.35137  , ...,  -2.4639065,
              -20.967506 ,  24.471956 ], dtype=float32)               ,
       array([ 84.89507 ,  99.943565, 214.93526 , ...,  19.976334,  28.742788,
               81.8274  ], dtype=float32)                                     ,
       array([53.39871  , 25.378992 , 34.994717 , ..., 11.56144  ,  1.1865733,
              -5.2332606], dtype=float32)                                     ,
       array([77.43302 , 57.608154, 35.885918, ..., 11.779735, 13.329471,
              31.273205], dtype=float32)                                 ,
       array([41.439194 , 55.89048  , 90.46299  , ..., 36.842022 ,  3.0010796,
              19.664892 ], dtype=float32)                                     ,
       array([59.592953, 38.09869 , 28.365639, ..., -4.956496, 50.046185,
              24.11339 ], dtype=float32)                                 ,
       array([ 91.22556 ,  38.166435,  33.79191 , ..., -34.679836,   5.981435,
               -9.197896], dtype=float32)                                     ,
       array([56.669483, 16.02393 , 39.01368 , ..., 50.668037, 29.31681 ,
              37.33624 ], dtype=float32)                                 ,
       array([31.288486, 48.50248 , 38.411236, ..., 17.349613, 24.769352,
              30.091293], dtype=float32)                                 ,
       array([ 87.72175 ,  50.413372,  61.38969 , ...,  23.250679, -23.209608,
              -19.284384], dtype=float32)                                     ,
       array([101.22931  ,  44.975456 ,  12.402562 , ...,   6.3223596,
               -0.9393209,  49.30059  ], dtype=float32)               ,
       array([44.942562 , 17.764109 , -3.8525138, ..., 50.02464  , 44.12366  ,
              60.690628 ], dtype=float32)                                     ,
       array([ 59.20814 ,  55.613914,  27.91828 , ..., -19.55956 ,   8.29092 ,
               10.887796], dtype=float32)                                     ,
       array([34.295227, 40.329224, 27.9551  , ..., 46.454773, 49.1931  ,
              69.531204], dtype=float32)                                 ,
       array([36.315937, 16.00898 , 23.807787, ..., 12.86178 , 15.712359,
              36.241283], dtype=float32)                                 ,
       array([-11.373059,  19.722734,  67.290306, ...,  -7.165212,   9.053778,
               34.411457], dtype=float32)                                     ,
       array([194.08597   , 109.600555  ,  82.694244  , ...,  24.634703  ,
               -0.36928344,  12.418137  ], dtype=float32)                 ,
       array([101.313965, 119.71282 , 130.68394 , ...,  13.80005 ,  28.10153 ,
               50.103584], dtype=float32)                                     ,
       array([64.63078  , 11.5607605, 46.99132  , ..., 10.160641 , 20.685055 ,
              -4.3322005], dtype=float32)                                     ,
       array([197.16518 , 137.81369 , 151.69016 , ...,  93.813934, 135.25934 ,
              173.53221 ], dtype=float32)                                     ,
       array([ 79.66366  ,  65.36527  , 103.68922  , ...,  12.59105  ,
                4.5669346,  17.350101 ], dtype=float32)               ,
       array([75.899666 , 63.157513 , 65.33133  , ..., -6.027305 ,  1.8957654,
              35.439938 ], dtype=float32)                                     ,
       array([118.971115, 213.64085 , 244.43103 , ..., 399.9716  , 283.28424 ,
              450.00113 ], dtype=float32)                                     ,
       array([37.606575 , 55.526684 , -6.727203 , ...,  4.279816 ,  6.3283763,
              -3.4255786], dtype=float32)                                     ,
       array([50.402527 , 50.470436 , 74.56985  , ...,  3.7161267,  3.695714 ,
              32.50184  ], dtype=float32)                                     ,
       array([88.14448  , 38.538433 , 56.71485  , ...,  8.347698 , -4.6040545,
               3.8007746], dtype=float32)                                     ,
       array([ 43.81699  ,   6.0477796, -40.04479  , ...,  56.14445  ,
               23.531214 ,  32.211338 ], dtype=float32)               ,
       array([47.996475 , 23.217466 , 43.313095 , ..., -6.5125985,  4.0764008,
              15.212245 ], dtype=float32)                                     ,
       array([ 50.86098 , -16.722073, -49.73877 , ...,  18.018206,  14.292349,
               15.629646], dtype=float32)                                     ,
       array([ -4.5171566, -12.38693  ,   9.131368 , ...,  27.306553 ,
               39.90766  ,  45.29034  ], dtype=float32)               ,
       array([64.283516 , 48.341408 , 50.41997  , ..., -4.0912414,  1.0885363,
              11.414934 ], dtype=float32)                                     ,
       array([71.455345, 70.28768 , 79.49021 , ..., 34.40259 , 12.045274,
              33.09065 ], dtype=float32)                                 ,
       array([102.18409  , 109.295685 , 104.87101  , ..., -16.896778 ,
               16.433657 ,  -7.8815184], dtype=float32)               ,
       array([98.77656 , 47.87196 , 51.92575 , ..., 37.04617 , 46.86966 ,
              24.138018], dtype=float32)                                 ,
       array([70.01204 , 45.532265, 83.10735 , ..., -5.580532, 14.368292,
              16.913284], dtype=float32)                                 ,
       array([97.79851  , 89.1026   , 57.037685 , ..., 17.480164 ,  3.3304052,
               8.430007 ], dtype=float32)                                     ,
       array([-12.16726 , -78.80997 , -11.505411, ..., -35.295994,   5.180776,
              -71.18394 ], dtype=float32)                                     ,
       array([99.59899 , 90.554436, 92.35792 , ..., 28.075838, 23.272572,
              35.64472 ], dtype=float32)                                 ,
       array([83.29214 , 76.66511 , 53.969517, ..., 19.533796, 22.250977,
              25.362755], dtype=float32)                                 ],
      dtype=object)
In [89]:
np.vstack(F).shape
Out[89]:
(452, 40000)

Oracle score

The oracle score is a leave-one-out correlation for repeated segments of stimulus. It provides an estimate of visual response reliability for a given unit over the course of the scan. For more detail see the technical documentation found here. Oracle scores are found in `nda.Oracle`. *Note that only masks classified as "soma" in `nda.MaskClassification` currently have oracle scores computed. This may change in a future version.*
In [90]:
oracles = (nda.Oracle & scan_key).fetch('pearson')
In [91]:
fig, ax = plt.subplots()
ax.hist(oracles, bins=50, color='k');
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
In [92]:
high_oracle_percentile = np.percentile(oracles, 99)
Oracle scores greater than a threshold value can be specified by restricting the table with a string: `'pearson>x'` where `x` is the oracle value threshold.
In [93]:
high_oracle_percentile
Out[93]:
0.54185948
In [94]:
high_oracle_table = nda.Oracle & scan_key & f'pearson>{high_oracle_percentile}'
high_oracle_table
Out[94]:
Leave-one-out correlation for repeated videos in stimulus.

session

Session ID

scan_idx

Scan ID

unit_id

unique per scan

trials

number of trials used

pearson

per unit oracle pearson correlation over all movies
4 7 130 60 0.623745
4 7 327 60 0.61131
4 7 493 60 0.54457
4 7 688 60 0.561252
4 7 756 60 0.617953
4 7 775 60 0.638734
4 7 795 60 0.613519
4 7 907 60 0.574646
4 7 1070 60 0.553697
4 7 1177 60 0.57389
4 7 1262 60 0.594857
4 7 1552 60 0.593425

...

Total: 75

Select the nth entry in the table by passing an `offset` and `limit` to the `fetch` method.
In [95]:
unit_key = high_oracle_table.fetch('KEY', offset=60, limit=1)[0]
unit_key
Out[95]:
{'session': 4, 'scan_idx': 7, 'unit_id': 5819}

Plot Oracle Raster

The function `fetch_oracle_raster` provided in the `func` module retrieves the responses for the functional unit for the repeated stimulus trials (oracle trials). This function is useful to study as a lesson in how to access data from particular clips.
In [96]:
oracle_traces, score = func.fetch_oracle_raster(unit_key)
In [97]:
fig,axes = plt.subplots(1,6, figsize=(6,1),dpi=300)
for col,clip_trace in zip(axes,np.moveaxis(oracle_traces,1,0)):
    col.imshow(clip_trace,cmap='binary', interpolation='nearest')
    col.set_aspect('auto')
    col.set_xticks([])
    col.set_yticks([])
axes[0].set_ylabel(f'oracle score: {score:.2f}', fontsize=5)
fig.subplots_adjust(wspace=.05)
[ax.set_title(f'oracle clip {i+1}', fontsize=6) for i, ax in enumerate(axes)];
fig.suptitle(f'session: {unit_key["session"]}, scan_idx: {unit_key["scan_idx"]}, unit_id: {unit_key["unit_id"]}', fontsize=7, y=1.2)
Out[97]:
Text(0.5, 1.2, 'session: 4, scan_idx: 7, unit_id: 5819')

Spike Traces

Spike traces are in `nda.Activity` and associated with single units (`unit_id's`). This is a derived data product from the fluorescnece which tries to deconvolve the fluorescence into a series of impulse functions of different heights to reduce the effects of calcium dynamics and noise in the fluorescence traces.
In [98]:
nda.Activity() & unit_key
Out[98]:
activity inferred from fluorescence traces

session

Session ID

scan_idx

Scan ID

unit_id

unique per scan

trace

spike trace
4 7 5819 =BLOB=

Total: 1

In [99]:
spike_trace = (nda.Activity() & unit_key).fetch1('trace')
In [100]:
fig, ax = plt.subplots(figsize=(10, 3), dpi=150)
ax.plot(spike_trace, c='k')
ax.set_xlabel('Frames')
ax.set_ylabel('Spike trace')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)

View fluorescence trace, and spike trace for the same unit

Use `nda.ScanUnit` to bridge between `unit_id` and `mask_id` to plot both the calcium trace spike trace and for a single unit.
In [101]:
nda.Fluorescence & (nda.ScanUnit & unit_key)
Out[101]:
fluorescence traces before spike extraction or filtering

session

Session ID

scan_idx

Scan ID

field

Field Number

mask_id

mask ID, unique per field

trace

fluorescence trace
4 7 6 460 =BLOB=

Total: 1

In [102]:
calcium_trace = (nda.Fluorescence & (nda.ScanUnit & unit_key)).fetch1('trace')
In [103]:
fig, ax = plt.subplots(figsize=(10, 3), dpi=150)
ax.plot(calcium_trace/ np.max(calcium_trace), c='g', alpha=0.5, label='calcium')
ax.plot(spike_trace/ np.max(spike_trace), c='k', label='spike', alpha=0.5)
ax.set_xlabel('Frames')
ax.legend()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
In [104]:
# lets zoom in to see the relationship more clearly
fig, ax = plt.subplots(figsize=(10, 3), dpi=150)
ax.plot(calcium_trace[4000:4500]/ np.max(calcium_trace), c='g', alpha=0.5, label='Fluorscence')
ax.plot(spike_trace[4000:4500]/ np.max(spike_trace), c='k', label='Activity', alpha=0.5)
ax.set_xlabel('Frames')
ax.set_ylabel('Aribtrary Units')
ax.legend()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)

Function - Structure Coregistration

Now that you understand how to access the activity of individual units, how do you relate those units to cells in the structural dataset? We do this by registering the imaging data in vivo to the ex vivo EM structural data through a series of transforms and finally some manual validation of the correspondance. You can skip over the details of how we do that, and instead focus just on the table of manually verified co-registration results, which are available as a table in the caveclient. There are almost 10K cells available that, and contain this co-registration. Lets look at this table with the caveclient.
In [105]:
import caveclient
client = caveclient.CAVEclient('minnie65_public_v343')
cr_df = client.materialize.query_table('functional_coreg')
cr_df.head()
Out[105]:
id valid pt_supervoxel_id pt_root_id session scan_idx unit_id pt_position
0 1 t 102531727972419182 864691136136642173 4 7 665 [274864, 94064, 22046]
1 2 t 94792540099826672 864691136208993724 4 7 740 [218320, 104320, 19016]
2 4 t 93946810036875732 864691135683934135 4 7 782 [212128, 94544, 23423]
3 5 t 84730565597057981 864691135334528233 4 7 855 [145158, 110036, 19355]
4 6 t 110905058841147285 864691136309730650 4 7 921 [335744, 90128, 22805]
Each row is a functional ROI which has been linked to the EM. You can see the important columns here are * **pt_root_id** : the seg_id/root_id of the EM segmentation * **session** : the session of this ScanUnit * **scan_idx** : the scan_idex of this ScanUnit * **unit_id** : the unit_id of this unit_id We can use rows from this dataframe to restrict the ScanUnit table
In [106]:
coreg_scan_units_top50 = pd.DataFrame(nda.ScanUnit() & cr_df.head(50))
coreg_scan_units_top50.head()
Out[106]:
session scan_idx unit_id field mask_id um_x um_y um_z px_x px_y ms_delay
0 4 7 665 2 22 160 -308 80 150 191 27
1 4 7 740 2 97 37 -78 80 101 283 31
2 4 7 782 2 139 229 -15 80 177 308 32
3 4 7 855 2 212 65 249 80 112 413 37
4 4 7 921 2 278 190 -578 80 162 83 23
In [107]:
print(len(coreg_scan_units_top50))
50
And lets pull out the flourescence from these units
In [108]:
first5_fluorescence=(nda.Fluorescence & coreg_scan_units_top50).fetch('trace')
In [109]:
# this comes back as array of arrays
# lets make it a matrix
first5_flourescence = np.vstack(first5_fluorescence)
In [110]:
first5_flourescence.shape
Out[110]:
(50, 40000)
In [111]:
# lets plot the raw values for the first 200 frames
f, ax = plt.subplots()
lines=ax.plot(first5_flourescence.T[0:2000,:])
ax.set_xlabel('frames')
ax.set_ylabel('fluorescence (AU)')
Out[111]:
Text(0, 0.5, 'fluorescence (AU)')

Exercise 1: Plot the fluorescence and activity trace of the highest oracle scoring proofread layer 2/3 pyramidal cell

In [112]:
# merge proofreading status and cell type predictions to find an extended axons of the right type
prf_df = client.materialize.query_table('proofreading_status_public_release', 
                                       filter_equal_dict={'status_axon':'extended'})
ct_df = client.materialize.query_table('aibs_soma_nuc_metamodel_preds_v117', 
                                       filter_equal_dict={'cell_type':'23P'})
dfm = pd.merge(prf_df, ct_df, on='pt_root_id', how='inner')

dfm.shape
Out[112]:
(28, 20)
In [113]:
# merge in the co-registration to find which are coregistered.
coreg_df = client.materialize.query_table('functional_coreg')
dfm2 = pd.merge(dfm, coreg_df, on='pt_root_id', how='inner')
dfm2.shape
Out[113]:
(37, 27)
In [114]:
# use datajoint to find the oracle scores for these units 
oracle_score_df = pd.DataFrame(nda.Oracle() & dfm2)
oracle_score_df
Out[114]:
session scan_idx unit_id trials pearson
0 4 7 3454 60 0.347168
1 4 7 3533 60 0.389768
2 4 7 3633 60 0.389276
3 4 7 3634 60 0.377085
4 4 7 3753 60 0.396725
5 5 3 1494 60 0.245851
6 5 3 2300 60 0.195357
7 5 3 2528 60 0.246312
8 5 6 2365 60 0.400285
9 5 7 2529 60 0.389749
10 6 2 2464 60 0.149385
11 6 4 2313 60 0.295697
12 6 4 4754 60 0.552235
13 6 4 4805 60 0.503934
14 6 6 3607 60 0.269975
15 6 6 4310 60 0.341804
16 6 7 3657 60 0.366028
17 6 7 4548 60 0.137352
18 7 3 1469 60 0.336497
19 7 3 1847 60 0.175136
20 7 4 2705 60 0.253142
21 7 4 5849 60 0.413953
22 7 5 1505 60 0.134061
23 7 5 2220 60 0.319839
24 7 5 2237 60 0.467668
25 7 5 2245 60 0.357210
26 7 5 4171 60 0.416111
27 7 5 4749 60 0.644044
28 7 5 4795 60 0.351339
29 8 5 2039 60 0.419923
30 8 5 2491 60 0.452308
31 8 5 4960 60 0.435012
32 8 5 5031 60 0.301440
33 8 5 5094 60 0.286198
34 9 4 2058 60 0.334003
35 9 4 5224 60 0.337876
36 9 4 7086 60 0.305401
In [115]:
# find the unit with the highest oracle score 
oracle_score_df.sort_values('pearson', ascending=False)
Out[115]:
session scan_idx unit_id trials pearson
27 7 5 4749 60 0.644044
12 6 4 4754 60 0.552235
13 6 4 4805 60 0.503934
24 7 5 2237 60 0.467668
30 8 5 2491 60 0.452308
31 8 5 4960 60 0.435012
29 8 5 2039 60 0.419923
26 7 5 4171 60 0.416111
21 7 4 5849 60 0.413953
8 5 6 2365 60 0.400285
4 4 7 3753 60 0.396725
1 4 7 3533 60 0.389768
9 5 7 2529 60 0.389749
2 4 7 3633 60 0.389276
3 4 7 3634 60 0.377085
16 6 7 3657 60 0.366028
25 7 5 2245 60 0.357210
28 7 5 4795 60 0.351339
0 4 7 3454 60 0.347168
15 6 6 4310 60 0.341804
35 9 4 5224 60 0.337876
18 7 3 1469 60 0.336497
34 9 4 2058 60 0.334003
23 7 5 2220 60 0.319839
36 9 4 7086 60 0.305401
32 8 5 5031 60 0.301440
11 6 4 2313 60 0.295697
33 8 5 5094 60 0.286198
14 6 6 3607 60 0.269975
20 7 4 2705 60 0.253142
7 5 3 2528 60 0.246312
5 5 3 1494 60 0.245851
6 5 3 2300 60 0.195357
19 7 3 1847 60 0.175136
10 6 2 2464 60 0.149385
17 6 7 4548 60 0.137352
22 7 5 1505 60 0.134061
In [116]:
unit_key={'session':7, 'scan_idx':5, 'unit_id':4754}
In [119]:
# pull out its fluorescence
F=((nda.ScanUnit()&unit_key)*nda.Fluorescence).fetch1('trace')
In [120]:
# pull out its activity
act=((nda.ScanUnit()&unit_key)*nda.Activity()).fetch1('trace')
In [121]:
# plot them together
# lets zoom in to see the relationship more clearly
fig, ax = plt.subplots(figsize=(10, 3), dpi=150)
ax.plot(F[4000:4500], c='g', alpha=0.5, label='Fluorscence')
#ax.plot(act[4000:4500]/ np.max(act), c='k', label='Activity', alpha=0.5)
ax.set_xlabel('Frames')
ax.set_ylabel('Aribtrary Units')
ax.legend()
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)

Exercise 2: Find the ScanUnits within a field with the largest average response to the monet stimulus in a scan. Find out which of these are coregistered to the structural data. Which direction has the largest response? How consistent is that response across other monet stimuli with the same directions?

In [122]:
# filter out the Trial table for the unit you selected in Exercise 1 and the Monet type

nda.ScanUnit() & field_key
Out[122]:
single unit in the scan

session

Session ID

scan_idx

Scan ID

unit_id

unique per scan

field

Field Number

mask_id

mask id unique per field

um_x

centroid x motor coordinates (microns)

um_y

centroid y motor coordinates (microns)

um_z

centroid z motor coordinates (microns)

px_x

centroid x pixel coordinate in field (pixels)

px_y

centroid y pixel coordinate in field (pixels)

ms_delay

delay from start of frame (field 1 pixel 1) to recording of this unit (milliseconds)
4 7 2551 4 1 -180 -780 220 14 2 58
4 7 2552 4 2 -109 -758 220 42 11 58
4 7 2553 4 3 -21 -750 220 77 14 59
4 7 2554 4 4 16 -738 220 93 19 59
4 7 2555 4 5 48 -751 220 105 14 59
4 7 2556 4 6 88 -755 220 121 12 59
4 7 2557 4 7 99 -754 220 126 13 59
4 7 2558 4 8 124 -750 220 136 14 59
4 7 2559 4 9 137 -763 220 141 9 58
4 7 2560 4 10 117 -782 220 133 1 58
4 7 2561 4 11 162 -778 220 151 3 58
4 7 2562 4 12 169 -749 220 153 14 59

...

Total: 1389

In [123]:
# pick a field key
field_key
Out[123]:
{'session': 4, 'scan_idx': 7, 'field': 4}
In [124]:
# pick out the fluorescence for these units as a N x 40000 matrix
fluor=(nda.ScanUnit() & field_key) * nda.Fluorescence()
F =np.vstack(fluor.fetch('trace'))
In [125]:
# pick out the activity for these units as a N x 40000 matrix
act=(nda.ScanUnit() & field_key) * nda.Activity()
A =np.vstack(act.fetch('trace'))
In [126]:
F.shape, A.shape
Out[126]:
((1389, 40000), (1389, 40000))
In [127]:
# get the frame times for the scan
frame_times=(nda.FrameTimes()&field_key).fetch1('frame_times')
In [128]:
# get the monet trials for this frame from the Trial table as a dataframe
monet_trials=pd.DataFrame((nda.Trial() & field_key & {'type':'stimulus.Monet2'}))
monet_trials.head()
Out[128]:
session scan_idx trial_idx type start_idx end_idx start_frame_time end_frame_time frame_times condition_hash
0 4 7 6 stimulus.Monet2 436 530 69.112716 84.095809 [69.11271565244505, 69.12939541623899, 69.1460... DKYV7TrfEl+C8nvadH+1
1 4 7 7 stimulus.Monet2 531 625 84.179131 99.162216 [84.17913143918821, 84.19580333516905, 84.2124... +rgSVBVRE8Ij1WNhq8ZW
2 4 7 8 stimulus.Monet2 626 720 99.245546 114.228632 [99.24554627225706, 99.26221435354063, 99.2788... GHn0W57E+2PS+Qr5yD2r
3 4 7 9 stimulus.Monet2 721 815 114.311966 129.295058 [114.31196635053465, 114.32862942502805, 114.3... u0ftbdrw9UHzSHDe1o4f
4 4 7 88 stimulus.Monet2 6139 6233 974.497840 989.480919 [974.4978403358252, 974.5145055560859, 974.531... WdUz9wrTqcT0KJgVrQeF
In [129]:
# loop over the monet trials and sum the fluorescence during the monet trials across time
# collect the mean of these responses for neurons in the field
monet_responses = []
for k,trial in monet_trials.iterrows():
    Fclip=np.mean(F[:, trial.start_idx:trial.end_idx], axis=1)
    monet_responses.append(Fclip)
monet_responses=np.vstack(monet_responses)
monet_responses.shape
Out[129]:
(40, 1389)
In [130]:
# plot the responses across the monet Trials
f,ax = plt.subplots()
lines=ax.plot(monet_responses.T)
ax.set_xlabel('neuron')
ax.set_ylabel('summed F')
Out[130]:
Text(0, 0.5, 'summed F')
In [131]:
# order the neurons by their mean response across trials. 
# use this to pick out the index of the kth most responsive neuron
mean_response = np.mean(monet_responses, axis=0)
max_neuron = np.argsort(mean_response)[-10]
max_neuron
Out[131]:
1238
In [132]:
# plot this neuron across the monet trials
plt.plot(monet_responses[:,max_neuron])
plt.xlabel('monet trials')
plt.ylabel('avg fluorescence')
Out[132]:
Text(0, 0.5, 'avg fluorescence')
In [133]:
# plot out the raw fluorescence data from one of the highly responsive trials
high_trial=monet_trials.loc[2,:]
f, ax = plt.subplots()
high_trial_F = F[max_neuron, high_trial.start_idx:high_trial.end_idx]
ax.plot(high_trial_F)
ax.set_xlabel('frames')
ax.set_ylabel('fluorescence')
# plot out the activity  data from that same highly responsive trials
high_trial_A = A[max_neuron, high_trial.start_idx:high_trial.end_idx]
f, ax = plt.subplots()
ax.plot(high_trial_A)
ax.set_xlabel('frames')
ax.set_ylabel('activity')
Out[133]:
Text(0, 0.5, 'activity')
In [134]:
# cutout each of the directions, reorder them 
#and plot the fluorescence by direction

# first construct the directions dataframe as we did above for this trial
# hint, filter on nda.Monet2 with the high trial row converted to a dictionary
monet_info = nda.Monet2& high_trial.to_dict()
directions, onsets = monet_info.fetch1('directions', 'onsets')
directions_df = pd.DataFrame({'onset': onsets[0,:], 'direction':directions[0,:]})
duration = float(monet_info.fetch1('duration'))
offsets = np.concatenate([directions_df['onset'][1:],[duration]])
directions_df['offset']=offsets
directions_df['onset_time']=directions_df['onset']+high_trial['start_frame_time']
directions_df['offset_time']=directions_df['offset']+high_trial['start_frame_time']

directions_df['onset_frame_number']=np.searchsorted(frame_times, directions_df.onset_time)
directions_df['offset_frame_number']=np.searchsorted(frame_times, directions_df.offset_time)

# sort the times with respect to directions
directions_df.sort_values('direction', inplace=True)
directions_df
Out[134]:
onset direction offset onset_time offset_time onset_frame_number offset_frame_number
13 12.1875 0.0 13.1250 111.433046 112.370546 703 708
6 5.6250 22.5 6.5625 104.870546 105.808046 661 667
3 2.8125 45.0 3.7500 102.058046 102.995546 643 649
4 3.7500 67.5 4.6875 102.995546 103.933046 649 655
1 0.9375 90.0 1.8750 100.183046 101.120546 632 638
11 10.3125 112.5 11.2500 109.558046 110.495546 691 697
15 14.0625 135.0 15.0000 113.308046 114.245546 714 720
12 11.2500 157.5 12.1875 110.495546 111.433046 697 703
2 1.8750 180.0 2.8125 101.120546 102.058046 638 643
0 0.0000 202.5 0.9375 99.245546 100.183046 626 632
7 6.5625 225.0 7.5000 105.808046 106.745546 667 673
14 13.1250 247.5 14.0625 112.370546 113.308046 708 714
9 8.4375 270.0 9.3750 107.683046 108.620546 679 685
8 7.5000 292.5 8.4375 106.745546 107.683046 673 679
5 4.6875 315.0 5.6250 103.933046 104.870546 655 661
10 9.3750 337.5 10.3125 108.620546 109.558046 685 691
In [ ]:
 
In [135]:
# now loop through the directions and cutout the fluorescence and activity
# plot both, normalizing by the maximum seen in this trial

f, ax = plt.subplots(len(directions_df),1,figsize=(4,12))
n=0
for k,offsets in directions_df[['onset_frame_number', 'offset_frame_number']].iterrows():
    
    ax[n].plot(F[max_neuron, offsets['onset_frame_number']:offsets['offset_frame_number']]/np.max(high_trial_F))
    ax[n].plot(A[max_neuron, offsets['onset_frame_number']:offsets['offset_frame_number']]/np.max(high_trial_A))
    ax[n].set_ylim(0, 1)
    n+=1

Mean Intensity

The mean intensity of the calcium signal for the entire field is computed per frame for the duration of the scan. This is found in `nda.MeanIntensity`. Periods of low intensity may indicate a low quality stretch of scan, for example where water might have temporarily run out between the microscope objective and imaging site.
In [136]:
intensities = (nda.MeanIntensity & field_key).fetch1('intensities')
In [137]:
fig, ax = plt.subplots(figsize=(10, 3), dpi=150)
ax.plot(intensities, c='b', alpha=0.5)
ax.set_xlabel('Frames')
ax.set_ylabel('Field Mean Intensity')
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)

Behavior

Pupil

The pupil radius for each scan is found in `nda.RawManualPupil` and `nda.ManualPupil`. `pupil_min_r` is the smaller of the two radii from the ellipse fit to the pupil and `pupil_maj_r` is the larger radius. The tracked position of the pupil is found in `pupil_x` and `pupil_y`. `nda.RawManualPupil` contains the pupil traces and `pupil_times` at the original acquisition rate. `nda.ManualPupil` contains the pupil traces synced to the `field 1` scan times (found in the `field1_times` attribute in `nda.DepthTimes`)
In [138]:
nda.RawManualPupil() & scan_key
Out[138]:
Pupil traces

session

Session ID

scan_idx

Scan ID

pupil_min_r

vector of pupil minor radii synchronized with field 1 frame times (pixels)

pupil_maj_r

vector of pupil major radii synchronized with field 1 frame times (pixels)

pupil_x

vector of pupil x positions synchronized with field 1 frame times (pixels)

pupil_y

vector of pupil y positions synchronized with field 1 frame times (pixels)

pupil_times

vector of timestamps relative to scan start (seconds)
4 7 =BLOB= =BLOB= =BLOB= =BLOB= =BLOB=

Total: 1

In [139]:
nda.ManualPupil & scan_key
Out[139]:
Pupil traces

session

Session ID

scan_idx

Scan ID

pupil_min_r

vector of pupil minor radii synchronized with field 1 frame times (pixels)

pupil_maj_r

vector of pupil major radii synchronized with field 1 frame times (pixels)

pupil_x

vector of pupil x positions synchronized with field 1 frame times (pixels)

pupil_y

vector of pupil y positions synchronized with field 1 frame times (pixels)
4 7 =BLOB= =BLOB= =BLOB= =BLOB=

Total: 1

Treadmill

The treadmill velocity for each scan is found in `nda.RawTreadmill` and `nda.Treadmill`. `nda.RawTreadmill` contains the treadmill velocity trace and timestamps at the original acquisition rate. `nda.Treadmill` contains the treadmill velocity trace synced to the `field 1` scan times (found in the `field1_times` attribute in `nda.DepthTimes`)
In [140]:
nda.RawTreadmill & scan_key
Out[140]:
Treadmill traces

session

Session ID

scan_idx

Scan ID

treadmill_velocity

vector of treadmill velocities (cm/s)

treadmill_timestamps

vector of times relative to scan start (seconds)
4 7 =BLOB= =BLOB=

Total: 1

In [141]:
nda.Treadmill & scan_key
Out[141]:
Treadmill traces

session

Session ID

scan_idx

Scan ID

treadmill_velocity

vector of treadmill velocities synchronized with field 1 frame times (cm/s)
4 7 =BLOB=

Total: 1

Visualize area labels in 2P stack space

Area Membership

Computed area membership labels are found in `nda.AreaMembership`. View area labels for units in 2D space (x, y) in stack reference frame.
In [142]:
nda.AreaMembership()
Out[142]:

session

Session ID

scan_idx

Scan ID

unit_id

unique per scan

brain_area

Visual area membership of unit
4 7 1 LM
4 7 2 LM
4 7 3 LM
4 7 4 LM
4 7 5 LM
4 7 6 LM
4 7 7 LM
4 7 8 LM
4 7 9 LM
4 7 10 LM
4 7 11 LM
4 7 12 LM

...

Total: 168971

Let's pull out the area membership of every stack unit, and use it to color a scatter plot
In [143]:
area, x, y = (nda.AreaMembership * nda.StackUnit).fetch('brain_area', 'stack_x', 'stack_y')
In [144]:
color_dict = {'LM':'blue', 'AL': 'green', 'RL': 'purple', 'V1': 'red'}
In [145]:
fig, ax = plt.subplots(dpi=200)
ax.scatter(x, y, color=[color_dict[a] for a in area], s=1)
ax.set_aspect('equal')
ax.invert_yaxis()
ax.set_xlabel('2P stack x-axis')
ax.set_ylabel('2P stack y-axis')
ax.annotate('LM', (500, 300))
ax.annotate('AL', (900, 150))
ax.annotate('RL', (1100, 350))
ax.annotate('V1', (800, 600))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)